Yurii Hierts
Yurii Hierts

Reputation: 1920

Videojs, How to update m3u8 playlist dynamically

I want to add new incoming chunks from backend to the player which is already plaing "live" m3u8 playlist

This is an existing playlist (already set and playing)

#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PROGRAM-DATE-TIME:2018-10-19T16:39:07Z
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
#EXT-X-ENDLIST

This is an updated playlist, I want to replace old playlist (listed under) with the next one, but I don't want to reload videojs player with comand (player.src(...))

#EXTM3U
#EXT-X-PLAYLIST-TYPE:VOD
#EXT-X-TARGETDURATION:6
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-PROGRAM-DATE-TIME:2018-10-19T16:39:07Z
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
#EXTINF:6.000,
56-06000.ts
....
....
many another chunks
....
....
#EXT-X-ENDLIST

How can I do this? Or maybe any other good way to update playlist is existing?

Upvotes: 2

Views: 3726

Answers (1)

szatmary
szatmary

Reputation: 31100

Change the playlist type to EVENT, and don’t write an end tag. Then the player will keep requesting an updated playlist. For more information, please read the spec. https://www.rfc-editor.org/rfc/rfc8216

Upvotes: 6

Related Questions