Skip to content

Commit

Permalink
fix: Fix playback stuck on initial gap (#6340)
Browse files Browse the repository at this point in the history
Fixes #6339
  • Loading branch information
vlazh authored and avelad committed Apr 8, 2024
1 parent 9683c9d commit a621642
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 0 deletions.
1 change: 1 addition & 0 deletions karma.conf.js
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-raw-aac/*', included: false},
{pattern: 'test/test/assets/hls-raw-ac3/*', included: false},
Expand Down
12 changes: 12 additions & 0 deletions lib/player.js
Expand Up @@ -6019,6 +6019,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
Expand Up @@ -1382,4 +1382,17 @@ describe('Player', () => {
expect(thumbnails.length).toBe(3);
});
}); // describe('addThumbnailsTrack')

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
@@ -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.

0 comments on commit a621642

Please sign in to comment.