import 'package:flutter/material.dart'; import 'package:photo_view/photo_view.dart'; import 'package:qhd_prevention/customWidget/video_player_widget.dart'; import 'package:qhd_prevention/pages/my_appbar.dart'; import 'package:video_player/video_player.dart'; // 查看视频 class BigVideoViewer extends StatefulWidget { const BigVideoViewer({Key? key, required this.videoUrl}) : super(key: key); final String videoUrl; @override State createState() => _BigVideoViewerState(); } class _BigVideoViewerState extends State { VideoPlayerController? _videoController; @override void initState() { // TODO: implement initState super.initState(); _videoController?.removeListener(_controllerListener); _videoController?.dispose(); _videoController = VideoPlayerController.networkUrl(Uri.parse(widget.videoUrl)) ..initialize().then((_) { _videoController! ..play() ..addListener(_controllerListener); }); } void _controllerListener() { if (mounted) setState(() {}); } @override void dispose() { _videoController?.dispose(); super.dispose(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: MyAppbar( backgroundColor: Colors.transparent, title: '', ), body: SafeArea(child: Center( child: VideoPlayerWidget( allowSeek: false, controller: _videoController, coverUrl:"", aspectRatio: _videoController?.value.aspectRatio ?? 16/9, ), ),) ); } }