8
votes

I have a HLS stream with #EXT-X-PLAYLIST-TYPE:EVENT in the playlist. This plays correctly in Safari, except that seeking is not available until #EXT-X-ENDLIST is appended to the playlist.

To my understanding, playlists with #EXT-X-PLAYLIST-TYPE:EVENT contain all segments of the video so far. That is, new segments may be appended, but existing segments can not be removed or modified. If previous segments are effectively immutable, then shouldn't the video player in Safari allow the user to seek backwards to earlier in the video? Instead, the player just says "Live Broadcast" and has no scrubbing control until the #EXT-X-ENDLIST is appended to the playlist.

Technical Note TN2288 says this (emphasis mine):

An event playlist is specified by the EXT-X-PLAYLIST-TYPE tag with a value of EVENT. An event playlist looks just like a live playlist to start out with. It doesn't initially have an EXT-X-ENDLIST tag, indicating that new media files will be added to the playlist as they become available. However, with the EVENT tag, you cannot change the playlist at all; you may only append new segments to the end of the file. They cannot be added at the front. New segments are added until the event has concluded, at which time the EXT-X-ENDLIST tag is appended. As the name implies, event playlists are typically used for events such as concerts or sports games where you want to allow the user to seek anywhere in the event from the beginning.

It sounds to me like seeking should be possible with this kind of HLS playlist, so what am I missing?

2
Which kind of server are you using to publish your live stream because I think that there are some configurations to do in the server side ?akmozo
@akmozo HLS just serves static files through any web server.Tom Dalling
I just spent the last three hours fiddling with this, with nothing to show for it. All I can tell you is what didn't work: 1) creating a live playlist by removing EXT-X-PLAYLIST-TYPE alltogether 2) setting #EXT-X-PROGRAM-DATE-TIME for each segment 3) creating a master playlist + variant playlist + iframe-only playlist with iframe-playlist-generator. Sorry…janfoeh
@janfoeh I have a sneaking suspicion that this is actually a bug in MPMoviePlayerController, or whatever underlies it. I can't find anything authoritative that confirms that it used to work, though.Tom Dalling
I've tried in Safari 7 / Mavericks, Safari 8 / Yosemite and Mobile Safari for iOS 8 — whatever it is, it's been present for a while now. The thing is… have you ever watched Apples own keynotes live? I have, and I cannot remember seeking ever working even there. Neither could I find another HLS live source allowing it. Do you have a developer account that gives you access to Apples mediastreamvalidator?janfoeh

2 Answers

1
votes

The solution I've found as a workaround:

<script src="https://cdn.jsdelivr.net/npm/hls.js@latest"></script>
<video id="video" controls="controls"></video>
<script>
var video = document.getElementById('video');
var url = 'http://awesome.app/playlist.m3u8';
if (Hls.isSupported()) {
    var hls = new Hls({
        debug: true
    });
    hls.loadSource(url);
    hls.attachMedia(video);
    hls.on(Hls.Events.MANIFEST_PARSED, function () {
        video.play();
    });
}
</script>

The above starts at the most recently uploaded segment and allows seeking to earlier segments on Safari, Chrome, and Firefox.

-2
votes

If previous segments are effectively immutable, then shouldn't the video player in Safari allow the user to seek backwards to earlier in the video?

Yes, but the number of files available in your index file during a live session constrains the client's behavior when doing play/pause and seeking operations.

Try with at least 3 files in your index file with no #EXT-X-ENDLIST and you should be able to seek.

When you #EXT-X-ENDLIST to the playlist you are marking the event as concluded, therefore you are allowed to seek no matter how many files you have in your play list.