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

fix: Fix playback stuck on initial gap #6340

Merged
merged 10 commits into from
Mar 14, 2024
1 change: 1 addition & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
12 changes: 12 additions & 0 deletions lib/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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_();

Expand Down
13 changes: 13 additions & 0 deletions test/player_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});
Binary file added test/test/assets/6339/a.mp4
Binary file not shown.
37 changes: 37 additions & 0 deletions test/test/assets/6339/master.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?xml version="1.0" ?>
<MPD xmlns="urn:mpeg:dash:schema:mpd:2011" profiles="urn:mpeg:dash:profile:isoff-on-demand:2011" minBufferTime="PT9.98S" mediaPresentationDuration="PT84.00S" type="static">
<Period>
<AdaptationSet mimeType="video/mp4" segmentAlignment="true" startWithSAP="1" maxWidth="1280" maxHeight="720">
<Representation id="a4c937bb-6f30-4ecb-8301-09fc1fd94c30" codecs="avc1.4D401F" width="1280" height="720" scanType="progressive" frameRate="24" bandwidth="174395">
<SegmentList timescale="1000" duration="9982">
<Initialization sourceURL="v.mp4" range="36-745"/>
<SegmentURL media="v.mp4" mediaRange="746-18481"/>
<SegmentURL media="v.mp4" mediaRange="18482-32360"/>
<SegmentURL media="v.mp4" mediaRange="32361-46233"/>
<SegmentURL media="v.mp4" mediaRange="46234-60106"/>
<SegmentURL media="v.mp4" mediaRange="60107-73979"/>
</SegmentList>
</Representation>
</AdaptationSet>
<AdaptationSet mimeType="audio/mp4" segmentAlignment="true" startWithSAP="1">
<Label>Unknown</Label>
<Representation id="b68693a7-abb2-42bb-8d61-3646905df87a" codecs="mp4a.40.2" bandwidth="102962" audioSamplingRate="44100">
<SegmentList timescale="1000" duration="4000">
<Initialization sourceURL="a.mp4" range="36-663"/>
<SegmentURL media="a.mp4" mediaRange="664-3020"/>
<SegmentURL media="a.mp4" mediaRange="3021-5373"/>
<SegmentURL media="a.mp4" mediaRange="5374-7713"/>
<SegmentURL media="a.mp4" mediaRange="7714-10053"/>
<SegmentURL media="a.mp4" mediaRange="10054-12393"/>
<SegmentURL media="a.mp4" mediaRange="12394-14746"/>
<SegmentURL media="a.mp4" mediaRange="14747-17086"/>
<SegmentURL media="a.mp4" mediaRange="17087-19426"/>
<SegmentURL media="a.mp4" mediaRange="19427-21766"/>
<SegmentURL media="a.mp4" mediaRange="21767-24119"/>
<SegmentURL media="a.mp4" mediaRange="24120-26459"/>
<SegmentURL media="a.mp4" mediaRange="26460-28799"/>
</SegmentList>
</Representation>
</AdaptationSet>
</Period>
</MPD>
Binary file added test/test/assets/6339/v.mp4
Binary file not shown.