Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't jump over the gap at the beginning before the video is played so that the video poster doesn't disappear. #3645

Merged
merged 1 commit into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/media/gap_jumping_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
28 changes: 27 additions & 1 deletion test/media/playhead_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down