主要用到了 VideoPlay(VideoPlayController)ide
VideoPlayerController controller; bool initialized = false; @override void initState() { super.initState(); //初始化播放控件 controller= VideoPlayerController.file(widget.videoFile); //視頻初始化 controller.initialize().then((value){ initialized=true; //刷新頁面顯示播放器 setState(() { }); }); } @override Widget build(BuildContext context) { if (initialized) { final Size size = controller.value.size; return SizedBox(width:100.0,child:AspectRatio( aspectRatio: size.width / size.height, child: VideoPlayer(controller), )); } else { return new Container(); } }
前面須要導入ui
import 'package:video_player/video_player.dart'; import 'package:dio/dio.dart';