我怎么知道我是否已经播放了一段 M3U8 视频?

How can I know if I've already played a segment of an M3U8 video?

我正在编写一个 m3u8 播放器,但遇到了一个小问题。我正在尝试播放一个 m3u8 视频 returns 一个与片段文件名无关的媒体序列,文件名会永远重复。我怎么知道我是否已经播放了给定的片段?

这是几秒钟后请求的样子:

#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

几秒后:

#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

然后几秒钟后:

#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

因此片段名称相同,媒体序列并没有告诉我太多信息。我怎么知道我是否已经播放了那些特定片段?

谢谢。

片段名称无关紧要,您始终使用媒体序列。每次从播放列表中删除片段时,MEDIA-SEQUENCE 都会递增。

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.

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.

RFC 8216 - HTTP Live Streaming