4
votes

If I were to allow pausing of live HLS stream, I can keep the *.ts files stores for a longer period but how would I manage the m3u8 files?

As an example,

I am watching a live stream and want to pause for 5 minutes. When I click play again, I'd continue from where it was paused. At this point, the m3u8 files would be overwritten with the latest live segments, how do I keep the old m3u8 files so I can go back to play the old/paused segments?

Thanks!

1

1 Answers

1
votes

You can make your own playlist file in memory, and only ever append to it with the data retrieved from the web server. When the stream is paused you would still need to be refreshing the playlist(s). On resume, the player software would still know its current position in the stream.

Just be aware that there is no guarantee that the old segments will still be available. Often when serving HLS from a CDN, a time-to-live of just a few minutes is used. After that time period has expired, the CDN will just give a 404. That may or may not be relevant in your case; it depends on who controls the network infrastructure.