I'm writing an m3u8 player and have a small issue. One m3u8 video I'm trying to play returns a media sequence that has nothing to do with the segment file names and the file names repeat themselves forever. How can I know if I already played a given segment?
This is what the requests look like over a few seconds:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:5609
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:10
#EXTINF:10.000000,
channel001.ts
#EXTINF:10.000000,
channel000.ts
Then a few seconds later:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:5610
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:10
#EXTINF:10.000000,
channel000.ts
#EXTINF:10.000000,
channel001.ts
Then again a few seconds later:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:5611
#EXT-X-ALLOW-CACHE:YES
#EXT-X-TARGETDURATION:10
#EXTINF:10.000000,
channel001.ts
#EXTINF:10.000000,
channel000.ts
so the segment names are the same, the media sequence doesn't tell me much. How can I know if I already played those specific segments?
Thanks.
The segment names don't matter, you always use the media sequence. MEDIA-SEQUENCE
is incremented each time a segment is removed from the playlist.
3. Media Segments
...
Each segment in a Media Playlist has a unique integer Media Sequence Number. The Media Sequence Number of the first segment in the Media Playlist is either 0 or declared in the Playlist (Section 4.3.3.2). The Media Sequence Number of every other segment is equal to the Media Sequence Number of the segment that precedes it plus one.
and
6.3.5. Determining the Next Segment to Load
...
The first segment to load is generally the segment that the client has chosen to play first (see Section 6.3.3).
In order to play the presentation normally, the next Media Segment to load is the one with the lowest Media Sequence Number that is greater than the Media Sequence Number of the last Media Segment loaded.