d0183164 by David LaPalomento

Seeking in an empty playlist should not error

Seeking is clamped to the seekable ranges, which are empty for an empty playlist. Making seeking a harmless no-op to match the spec in this case.
1 parent 93d4e050
......@@ -315,6 +315,12 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
return 0;
}
// it's clearly an edge-case but don't thrown an error if asked to
// seek within an empty playlist
if (!this.playlists.media().segments) {
return 0;
}
// save the seek target so currentTime can report it correctly
// while the seek is pending
this.lastSeekedTime_ = currentTime;
......
......@@ -1321,6 +1321,19 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () {
equal(4, player.hls.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED');
});
test('seeking in an empty playlist is a non-erroring noop', function() {
player.src({
src: 'manifest/empty-live.m3u8',
type: 'application/vnd.apple.mpegurl'
});
openMediaSource(player);
requests.shift().respond(200, null, '#EXTM3U\n');
player.currentTime(183);
equal(player.currentTime(), 0, 'remains at time zero');
});
test('duration is Infinity for live playlists', function() {
player.src({
src: 'http://example.com/manifest/missingEndlist.m3u8',
......