wilz
wilz

Reputation: 55

How to play m3u8 links using flutters video_player or chewie or video_viewer plugin?

I have noticed some of the links are not working on iOS devices by using flutters video_player plugin, but If I use the below example link, it works well on all the devices even on android and iOS.

https://sfux-ext.sfux.info/hls/chapter/105/1588724110/1588724110.m3u8

below links are not working on iOS devices but works on android devices,

https://5421175365ea3.streamlock.net/live/smil:switch.smil/playlist.m3u8

https://dcunilive28-lh.akamaihd.net/i/dclive_1@533583/master.m3u8

any clue how can we make it work?

Upvotes: 2

Views: 3437

Answers (3)

Jenish MS
Jenish MS

Reputation: 455

Try video_player_web_hls to play m3u8 link on flutter web application.

Add following script tag in index.html file

<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"  type="application/javascript"></script>

Upvotes: 0

Stupid Dream
Stupid Dream

Reputation: 140

If you're using video_player you should comment the below code for ios

// The player may be initialized but still needs to determine the duration.
if ([self duration] == 0) {
  return;
}

In line number 315

YOUR_SDK_FOLDER\flutter\.pub-cache\hosted\pub.dartlang.org\video_player-your_player_version_no\Classes\FLTVideoPlayerPlugin.m

It seems like live hls stream is always returning duration=0

Upvotes: 2

ethergeist
ethergeist

Reputation: 619

Your HLS playlist is pretty boken and has a lot of issues, biggest one would the missing codec information.

Use Apples HTTP Livestreaming tools to validate your playlist.

Excerpt for your first link:

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

All these issues can prevent HLS from playing on Apple devices, Android might be a bit more lenient.

Upvotes: 0

Related Questions