| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  | 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<BigVideoViewer> createState() => _BigVideoViewerState(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class _BigVideoViewerState extends State<BigVideoViewer> { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   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: '', | 
					
						
							|  |  |  |       ), | 
					
						
							| 
									
										
										
										
											2025-08-29 09:52:48 +08:00
										 |  |  |       body: SafeArea(child: Center( | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |         child: VideoPlayerWidget( | 
					
						
							| 
									
										
										
										
											2025-08-29 09:52:48 +08:00
										 |  |  |           allowSeek: false, | 
					
						
							|  |  |  |           controller: _videoController, | 
					
						
							|  |  |  |           coverUrl:"", | 
					
						
							|  |  |  |           aspectRatio: _videoController?.value.aspectRatio ?? 16/9, | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2025-08-29 09:52:48 +08:00
										 |  |  |       ),) | 
					
						
							| 
									
										
										
										
											2025-07-23 20:14:38 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |