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) { ...@@ -315,6 +315,12 @@ videojs.Hls.prototype.setCurrentTime = function(currentTime) {
315 return 0; 315 return 0;
316 } 316 }
317 317
318 // it's clearly an edge-case but don't thrown an error if asked to
319 // seek within an empty playlist
320 if (!this.playlists.media().segments) {
321 return 0;
322 }
323
318 // save the seek target so currentTime can report it correctly 324 // save the seek target so currentTime can report it correctly
319 // while the seek is pending 325 // while the seek is pending
320 this.lastSeekedTime_ = currentTime; 326 this.lastSeekedTime_ = currentTime;
......
...@@ -1321,6 +1321,19 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () { ...@@ -1321,6 +1321,19 @@ test('segment 500 should trigger MEDIA_ERR_ABORTED', function () {
1321 equal(4, player.hls.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED'); 1321 equal(4, player.hls.error.code, 'Player error code should be set to MediaError.MEDIA_ERR_ABORTED');
1322 }); 1322 });
1323 1323
1324 test('seeking in an empty playlist is a non-erroring noop', function() {
1325 player.src({
1326 src: 'manifest/empty-live.m3u8',
1327 type: 'application/vnd.apple.mpegurl'
1328 });
1329 openMediaSource(player);
1330
1331 requests.shift().respond(200, null, '#EXTM3U\n');
1332
1333 player.currentTime(183);
1334 equal(player.currentTime(), 0, 'remains at time zero');
1335 });
1336
1324 test('duration is Infinity for live playlists', function() { 1337 test('duration is Infinity for live playlists', function() {
1325 player.src({ 1338 player.src({
1326 src: 'http://example.com/manifest/missingEndlist.m3u8', 1339 src: 'http://example.com/manifest/missingEndlist.m3u8',
......