From 59b48f0c8efbd28b13fae76a87a371bcc61c67c0 Mon Sep 17 00:00:00 2001 From: Jacob Trimble Date: Wed, 22 Nov 2017 14:12:47 -0800 Subject: [PATCH] Revert "Prevent gap jumping while seeking." 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 --- lib/media/playhead.js | 2 -- test/media/playhead_unit.js | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/media/playhead.js b/lib/media/playhead.js index 3c4e1c85c1..d215ec207c 100644 --- a/lib/media/playhead.js +++ b/lib/media/playhead.js @@ -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; diff --git a/test/media/playhead_unit.js b/test/media/playhead_unit.js index c9e8acf82b..8cbfeeac85 100644 --- a/test/media/playhead_unit.js +++ b/test/media/playhead_unit.js @@ -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}], @@ -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) { @@ -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); }