Flutter视频播放器init()尚未实现错误

6ovsh4lw  于 2023-03-03  发布在  Flutter
关注(0)|答案(1)|浏览(237)

我收到一个错误,显示为未实现错误(未实现错误:init()尚未实现。)
enter image description here
我尝试了这个代码,并期待到工作罚款,但我得到了一个错误,就像在这张照片

0yg35tkg

0yg35tkg1#

尝试以这种方式初始化视频播放器:

@override
  void initState() {
    super.initState();

    _initVideoPlayer();
  }

通过创建一个异步方法

void _initVideoPlayer() async {
    _videoPlayerController = VideoPlayerController.network(
        'https://flutter.github.io/assets-for-api-docs/assets/videos/butterfly.mp4');

    /// Initialize the video player
    await videoPlayerController.initialize();

    /// The rest of your code
    final chewieController = ChewieController(
      videoPlayerController: videoPlayerController,
      autoPlay: true,
      looping: true,
    );

    final playerWidget = Chewie(
      controller: chewieController,
    );
  }

相关问题