如何使hls/破折号视频为Flutter网站

23c0lvtd  于 2023-05-23  发布在  Flutter
关注(0)|答案(1)|浏览(230)

我正在使用视频播放器插件-plugin link
同样的代码适用于android,但不适用于web。

void initState() {
    super.initState();
    _controller = VideoPlayerController.network(
      
      'videourl.m3u8',
      formatHint: VideoFormat.hls,    
     
    );

    _controller.addListener(() {
      setState(() {});
    });
    _controller.setLooping(false);
    _controller.initialize();
}

我得到的确切错误是这样的:

Uncaught (in promise) Error: PlatformException(MEDIA_ERR_SRC_NOT_SUPPORTED, No further diagnostic information can be determined or provided., The video has been found to be unsuitable (missing or in a format not supported by your browser)., null)
    

    at Object.createErrorWithStack (errors.dart:284)
    at Object._rethrow (async_patch.dart:200)
    at async._AsyncCallbackEntry.new.callback (zone.dart:1413)
    at Object._microtaskLoop (schedule_microtask.dart:40)
    at _startMicrotaskLoop (schedule_microtask.dart:49)
    at async_patch.dart:166

我是否需要在这里添加任何额外的信息,使其适用于Web?

wi3ka0sx

wi3ka0sx1#

在flutter项目目录/web/index.html中的index.html文件中添加以下代码行

<script src="https://cdn.jsdelivr.net/npm/hls.js@1"></script>

相关问题