【问题标题】:How to play m3u8 links using flutters video_player or chewie or video_viewer plugin?如何使用flutters video_player或chewie或video_viewer插件播放m3u8链接?
【发布时间】:2021-06-19 21:19:47
【问题描述】:
【问题讨论】:
标签:
flutter
flutter-dependencies
flutter-video-player
【解决方案1】:
如果您使用的是 video_player,您应该注释下面的 ios 代码
// The player may be initialized but still needs to determine the duration.
if ([self duration] == 0) {
return;
}
在第 315 行
YOUR_SDK_FOLDER\flutter\.pub-cache\hosted\pub.dartlang.org\video_player-
your_player_version_no\Classes\FLTVideoPlayerPlugin.m
似乎实时 hls 流总是返回 duration=0
【解决方案2】:
您的 HLS 播放列表非常简陋,有很多问题,最大的问题是缺少编解码器信息。
使用Apples HTTP Livestreaming 工具验证您的播放列表。
第一个链接的摘录:
Must Fix Issues
1. Measured peak bitrate compared to master playlist declared value exceeds error tolerance
Master Playlist Stream Definition for All Variants
2. I-frame playlists ( EXT-X-I-FRAME-STREAM-INF ) MUST be provided to support scrubbing and scanning UI
Master Playlist
3. Your EXT-X-STREAM-INF and EXT-X-I-FRAME-STREAM-INF tags MUST always provide CODECS attribute
Master Playlist Stream Definition for All Variants
4. Your EXT-X-STREAM-INF and EXT-X-I-FRAME-STREAM-INF tags MUST always provide the RESOLUTION attribute if the rendition(s) include video
Master Playlist Stream Definition for All Variants
5. You MUST include the AVERAGE-BANDWIDTH attribute
Master Playlist Stream Definition for All Variants
6. Each EXT-X-STREAM-INF tag MUST have a FRAME-RATE attribute
Master Playlist Stream Definition for All Variants
7. The server MUST deliver playlists using gzip content-encoding
All Variants
Master Playlist
8. The EXT-X-PROGRAM-DATE-TIME tag MUST be present in every live/linear media playlist
All Variants
9. You MUST provide at least 6 segments in a live/linear playlist
All Variants
10. If EXT-X-INDEPENDENT-SEGMENTS is not in master playlist, then you MUST use the EXT-X-INDEPENDENT-SEGMENTS tag in all video media playlists
All Variants
所有这些问题都会阻止 HLS 在 Apple 设备上播放,Android 可能会更宽松一些。