Question

Does anyone know if I can change a m3u8 file dynamically during runtime of the app?

The scenario is as follows: lets say i have multiple .ts files ready to play in a sequence, for example 1.ts , 2.ts , 3.ts etc...

Now during run time, i want to change the order to 1.ts , 3.ts and only then 2.ts.

Is this possible?

Thanks,

Was it helpful?

Solution

The answer is in the HLS standard (August 2017):

The server MUST NOT change the Media Playlist file, except to:

o  Append lines to it (Section 6.2.1).

o  Remove Media Segment URIs from the Playlist in the order that they
 appear, along with any tags that apply only to those segments
 (Section 6.2.2).

o  Increment the value of the EXT-X-MEDIA-SEQUENCE or EXT-X-
 DISCONTINUITY-SEQUENCE tags (Section 6.2.2).

o  Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

Note the standard draft (circa 2012) from the original answer was slightly different:

The server MUST NOT change the Playlist file, except to:

Append lines to it (Section 6.2.1).

Remove media URIs from the Playlist in the order that they appear, along with any tags that apply only to those media URIs (Section 6.2.2).

Increment the value of the EXT-X-MEDIA-SEQUENCE tag (Section 6.2.2).

Add or remove EXT-X-STREAM-INF tags or EXT-X-I-FRAME-STREAM-INF tags (Section 6.2.4). Note that clients are not required to reload variant Playlist files, so changing them may not have immediate effect.

Add an EXT-X-ENDLIST tag to the Playlist (Section 6.2.1).

All in all, what you aim at is not supported by the protocol.

Anyway it's rather pointless as segments may correlate between themselves in order (has common key-frames).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top