Browse Source

Prevent loading first segment of live manifest - seek to and load segment at current time (#839)

* load after seeking to current time
* fix tests to load/remove segment at current time vs first segment
pull/6/head
marguinbc 9 years ago
committed by Jon-Carlos Rivera
parent
commit
5371ba24c8
  1. 5
      src/master-playlist-controller.js
  2. 16
      test/videojs-contrib-hls.test.js

5
src/master-playlist-controller.js

@ -675,8 +675,6 @@ export class MasterPlaylistController extends videojs.EventTarget {
// 4) the player has not started playing
!this.hasPlayed_) {
this.load();
// trigger the playlist loader to start "expired time"-tracking
this.masterPlaylistLoader_.trigger('firstplay');
this.hasPlayed_ = true;
@ -687,6 +685,9 @@ export class MasterPlaylistController extends videojs.EventTarget {
this.tech_.setCurrentTime(seekable.end(0));
}
// now that we seeked to the current time, load the segment
this.load();
return true;
}
return false;

16
test/videojs-contrib-hls.test.js

@ -1948,11 +1948,8 @@ QUnit.test('cleans up the buffer when loading live segments', function() {
};
this.player.tech_.trigger('play');
this.clock.tick(1);
// this.requests[1] is an aborted XHR
// since we are in a live stream that request is aborted by
// the seek-to-live behavior
standardXHRResponse(this.requests[2]);
// request first playable segment
standardXHRResponse(this.requests[1]);
QUnit.strictEqual(this.requests[0].url, 'liveStart30sBefore.m3u8',
'master playlist requested');
@ -2003,14 +2000,13 @@ QUnit.test('cleans up the buffer based on currentTime when loading a live segmen
};
this.player.tech_.trigger('play');
this.clock.tick(1);
// Change seekable so that it starts *after* the currentTime which was set
// based on the previous seekable range (the end of 80)
seekable = videojs.createTimeRanges([[100, 120]]);
// this.requests[1] is an aborted XHR
// since we are in a live stream that request is aborted by
// the seek-to-live behavior
standardXHRResponse(this.requests[2]);
// request first playable segment
standardXHRResponse(this.requests[1]);
QUnit.strictEqual(this.requests[0].url, 'liveStart30sBefore.m3u8', 'master playlist requested');
QUnit.equal(removes.length, 1, 'remove called');

Loading…
Cancel
Save