在 flutter 上播放视频

play video on flutter

我正在尝试在我的 flutter 项目上播放视频,但它不起作用,出现错误。 好像视频无法播放并给我播放错误和源错误。 下图所示的完整错误。 这是我的代码:

class _ChewieDemoState extends State<ChewieDemo> {
  TargetPlatform _platform;
  VideoPlayerController _videoPlayerController1;
 // VideoPlayerController _videoPlayerController2;
  ChewieController _chewieController;

  @override
  void initState() {
    super.initState();
    _videoPlayerController1 =  VideoPlayerController.asset('assets/numbervideo.mp4');
    //_videoPlayerController2 = VideoPlayerController.network(
     //   'https://youtu.be/68XVRhQQ49w');
    _chewieController = ChewieController(
      videoPlayerController: _videoPlayerController1,
      aspectRatio: 3 / 2,
      autoPlay: true,
      looping: true,
    );
  }

  @override
  void dispose() {
    _videoPlayerController1.dispose();
   // _videoPlayerController2.dispose();
    _chewieController.dispose();
    super.dispose();
  }

The error is:

您是否在 pubspec.yaml 中添加了视频或视频文件夹?这样做并在之后重新启动应用程序。 Pubspec.yaml:

assets:
- assets/videos/

飞镖文件:

VideoPlayerController.asset('assets/videos/numbervideo.mp4');