Skip to content

Commit

Permalink
Revert "Prevent gap jumping while seeking."
Browse files Browse the repository at this point in the history
This also changes the tests so they mirror the |video.seeking|
property to reveal the problem that change created.  That change
broke seeking into gaps and gaps before the start.

Issue #1149
Issue #1150
Reopens #1061

Change-Id: I18fb65b1529acdacd0becd77078780625e0a955b
  • Loading branch information
TheModMaker committed Nov 22, 2017
1 parent f0c8509 commit 59b48f0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 0 additions & 2 deletions lib/media/playhead.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ shaka.media.Playhead.prototype.onSeekingToStartTime_ = function() {
shaka.media.Playhead.prototype.onPollGapJump_ = function() {
// Don't gap jump before the video is ready to play.
if (this.video_.readyState == 0) return;
// Don't gap jump while seeking, to prevent a race condition.
if (this.video_.seeking) return;
// Don't gap jump while paused, so that you don't constantly jump ahead while
// paused on a livestream.
if (this.video_.paused) return;
Expand Down
17 changes: 17 additions & 0 deletions test/media/playhead_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,17 @@ describe('Playhead', function() {
expectEvent: false
});

seekTest('will wait to jump when seeking backwards', {
// [20-30]
buffered: [{start: 20, end: 30}],
// The lack of newBuffered means we won't append any segments, so we
// should still be waiting.
start: 24,
seekTo: 4,
expectedEndTime: 4,
expectEvent: false
});

seekTest('will jump when seeking backwards into gap', {
// [2-10], [20-30]
buffered: [{start: 20, end: 30}],
Expand Down Expand Up @@ -898,9 +909,12 @@ describe('Playhead', function() {
// Seek to the given position and update ready state.
video.currentTime = data.seekTo;
video.readyState = calculateReadyState(data.buffered, data.seekTo);
video.seeking = true;
video.on['seeking']();
if (video.readyState < HTMLMediaElement.HAVE_ENOUGH_DATA)
video.on['waiting']();
else
video.seeking = false;
jasmine.clock().tick(1000);

if (data.newBuffered) {
Expand All @@ -911,8 +925,11 @@ describe('Playhead', function() {

// Now StreamingEngine will buffer the new content and tell playhead
// about it.
expect(video.currentTime).toBe(data.seekTo);
video.buffered = createFakeBuffered(data.newBuffered);
video.readyState = calculateReadyState(data.newBuffered, data.seekTo);
if (video.readyState >= HTMLMediaElement.HAVE_ENOUGH_DATA)
video.seeking = false;
playhead.onSegmentAppended();
jasmine.clock().tick(1000);
}
Expand Down

0 comments on commit 59b48f0

Please sign in to comment.