mirror of
https://github.com/shaka-project/shaka-player.git
synced 2026-06-14 15:56:38 +03:00
Work around MediaSource duration bug.
Fixes #1967 Change-Id: Ie2a41cb17427316ce65cf180507c1fb1f2c6f11a
This commit is contained in:
@@ -1145,8 +1145,11 @@ shaka.media.StreamingEngine = class {
|
||||
// We should only do this if the duration needs to shrink.
|
||||
// Growing it by less than 1ms can actually cause buffering on
|
||||
// replay, as in https://github.com/google/shaka-player/issues/979
|
||||
// On some platforms, this can spuriously be 0, so ignore this case.
|
||||
// https://github.com/google/shaka-player/issues/1967,
|
||||
const duration = this.playerInterface_.mediaSourceEngine.getDuration();
|
||||
if (duration < this.manifest_.presentationTimeline.getDuration()) {
|
||||
if (duration != 0 &&
|
||||
duration < this.manifest_.presentationTimeline.getDuration()) {
|
||||
this.manifest_.presentationTimeline.setDuration(duration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -995,6 +995,27 @@ describe('StreamingEngine', () => {
|
||||
expect(timeline.setDuration).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
// https://github.com/google/shaka-player/issues/1967
|
||||
it('does not change duration when 0', () => {
|
||||
setupVod();
|
||||
mediaSourceEngine = new shaka.test.FakeMediaSourceEngine(segmentData);
|
||||
createStreamingEngine();
|
||||
|
||||
onStartupComplete.and.callFake(() => setupFakeGetTime(0));
|
||||
onChooseStreams.and.callFake(defaultOnChooseStreams);
|
||||
|
||||
// The duration can spuriously be set to 0, so we should ignore this and not
|
||||
// update the duration.
|
||||
mediaSourceEngine.getDuration.and.returnValue(0);
|
||||
|
||||
// Here we go!
|
||||
streamingEngine.start();
|
||||
|
||||
runTest();
|
||||
expect(mediaSourceEngine.endOfStream).toHaveBeenCalled();
|
||||
expect(timeline.setDuration).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('applies fudge factor for appendWindowStart', () => {
|
||||
setupVod();
|
||||
mediaSourceEngine = new shaka.test.FakeMediaSourceEngine(segmentData);
|
||||
|
||||
Reference in New Issue
Block a user