diff --git a/lib/media/gap_jumping_controller.js b/lib/media/gap_jumping_controller.js index 42b0c0a220..e19edf5dc9 100644 --- a/lib/media/gap_jumping_controller.js +++ b/lib/media/gap_jumping_controller.js @@ -154,8 +154,10 @@ shaka.media.GapJumpingController = class { } // Don't gap jump while paused, so that you don't constantly jump ahead // while paused on a livestream. We make an exception for time 0, since we - // may be _required_ to seek on startup before play can begin. - if (this.video_.paused && this.video_.currentTime != 0) { + // may be _required_ to seek on startup before play can begin, but only if + // autoplay is enabled. + if (this.video_.paused && (this.video_.currentTime != 0 || + (!this.video_.autoplay && this.video_.currentTime == 0))) { return; } diff --git a/test/media/playhead_unit.js b/test/media/playhead_unit.js index 8009bd382f..edbd016266 100644 --- a/test/media/playhead_unit.js +++ b/test/media/playhead_unit.js @@ -1296,12 +1296,13 @@ describe('Playhead', () => { }); // Regression test for https://github.com/google/shaka-player/issues/2987 - it('does gap jump if paused at 0', () => { + it('does gap jump if paused at 0 and has autoplay', () => { const buffered = [{start: 10, end: 20}]; video.buffered = createFakeBuffered(buffered); video.currentTime = 0; video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; video.paused = true; + video.autoplay = true; config.jumpLargeGaps = true; playhead = new shaka.media.MediaSourcePlayhead( @@ -1319,6 +1320,31 @@ describe('Playhead', () => { expect(video.currentTime).toBe(10); }); + // Regression test for https://github.com/google/shaka-player/issues/3451 + it('doesn\'t gap jump if paused at 0 and hasn\'t autoplay', () => { + const buffered = [{start: 10, end: 20}]; + video.buffered = createFakeBuffered(buffered); + video.currentTime = 0; + video.readyState = HTMLMediaElement.HAVE_ENOUGH_DATA; + video.paused = true; + video.autoplay = false; + + config.jumpLargeGaps = true; + playhead = new shaka.media.MediaSourcePlayhead( + video, + manifest, + config, + /* startTime= */ 0, + Util.spyFunc(onSeek), + Util.spyFunc(onEvent)); + + playhead.notifyOfBufferingChange(); + jasmine.clock().tick(500); + + // There should NOT have been a gap jump. + expect(video.currentTime).toBe(0); + }); + /** * @param {string} name * @param {SeekTestInfo} data