flutterflutter-video-playerflutter-android

How to get full duration of HLS video in flutter video_player on Android?


I'm trying to play HLS video in flutter video_player. I'm generating m3u8 file like this:

#EXT-X-VERSION:4
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:1609034710
#EXT-X-PLAYLIST-TYPE:EVENT
#EXTINF:10.0,
video_part1.ts
#EXTINF:10.0,
video_part2.ts
#EXTINF:10.0,
video_part3.ts
#EXTINF:10.0,
video_part4.ts
#EXTINF:10.0,
video_part5.ts

... // etc.

I do not change or delete old parts, only append new ones when they available.

Video plays normally, but when I check controller.value.duration it always shows 50 seconds - the duration of the first playlist before any updates, and it does not allow me to seekTo beyond that position.

I can count real duration from playlist, but question is: How can I put that duration into a player and seek to any position in it?


Solution

  • After some research:

    Ended up using flutter_playout for this task. It's NOT based on default video_player and does not have this bug (but probably has others, need to use it more), and it works!