Work around MediaSource duration bug.

Fixes #1967

Change-Id: Ie2a41cb17427316ce65cf180507c1fb1f2c6f11a
This commit is contained in:
Jacob Trimble
2019-06-26 10:45:52 -07:00
parent 83de1ad634
commit 60d2f1cc82
2 changed files with 25 additions and 1 deletions
+4 -1
View File
@@ -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);
}
}
+21
View File
@@ -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);