diff --git a/karma.conf.js b/karma.conf.js index e8875931c3..910821e602 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -235,6 +235,7 @@ module.exports = (config) => { {pattern: 'test/test/assets/*', included: false}, {pattern: 'test/test/assets/dash-multi-codec/*', included: false}, {pattern: 'test/test/assets/3675/*', included: false}, + {pattern: 'test/test/assets/6339/*', included: false}, {pattern: 'test/test/assets/dash-aes-128/*', included: false}, {pattern: 'test/test/assets/hls-aes-256/*', included: false}, {pattern: 'test/test/assets/hls-raw-aac/*', included: false}, diff --git a/lib/player.js b/lib/player.js index 2fe0da22b7..a137ace285 100644 --- a/lib/player.js +++ b/lib/player.js @@ -6262,6 +6262,18 @@ shaka.Player = class extends shaka.util.FakeEventTarget { // change. if (this.playhead_) { this.playhead_.notifyOfBufferingChange(); + // Skip the initial buffer gap + const startTime = this.mediaSourceEngine_.bufferStart(contentType); + if ( + !this.isLive() && + // If not paused then GapJumpingController will handle this gap. + this.video_.paused && + startTime != null && + startTime > 0 && + this.playhead_.getTime() < startTime + ) { + this.playhead_.setStartTime(startTime); + } } this.pollBufferState_(); diff --git a/test/player_integration.js b/test/player_integration.js index 84956b0cc7..7f95f5e854 100644 --- a/test/player_integration.js +++ b/test/player_integration.js @@ -1390,4 +1390,17 @@ describe('Player', () => { await video.play(); await waiter.waitUntilPlayheadReachesOrFailOnTimeout(video, 1, 10); }); + + describe('buffer gap', () => { + // Regression test for issue #6339. + it('skip initial buffer gap', async () => { + if (window.ManagedMediaSource) { + pending('Skipping test, only runs on MSE'); + } + // Ensure the video has loaded. + await player.load('/base/test/test/assets/6339/master.mpd'); + await waiter.timeoutAfter(10).waitForEvent(video, 'loadeddata'); + expect(video.currentTime).toBeGreaterThanOrEqual(0); + }); + }); }); diff --git a/test/test/assets/6339/a.mp4 b/test/test/assets/6339/a.mp4 new file mode 100644 index 0000000000..cd2d1af467 Binary files /dev/null and b/test/test/assets/6339/a.mp4 differ diff --git a/test/test/assets/6339/master.mpd b/test/test/assets/6339/master.mpd new file mode 100644 index 0000000000..1f259f04ad --- /dev/null +++ b/test/test/assets/6339/master.mpd @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/test/test/assets/6339/v.mp4 b/test/test/assets/6339/v.mp4 new file mode 100644 index 0000000000..49df181c37 Binary files /dev/null and b/test/test/assets/6339/v.mp4 differ