diff --git a/lib/media/streaming_engine.js b/lib/media/streaming_engine.js index b7f2cc8908..74ba285afd 100644 --- a/lib/media/streaming_engine.js +++ b/lib/media/streaming_engine.js @@ -1827,12 +1827,10 @@ shaka.media.StreamingEngine = class { }); if (!waitingForAnotherStreamToRecover) { - if (this.config_.maxDisabledTime > 0) { - const handled = this.playerInterface_.disableStream( - mediaState.stream, this.config_.maxDisabledTime); - if (handled) { - return; - } + const handled = this.playerInterface_.disableStream( + mediaState.stream, this.config_.maxDisabledTime); + if (handled) { + return; } // Reduction schedule: 80%, 60%, 40%, 20%, 16%, 12%, 8%, 4%, fail. // Note: percentages are used for comparisons to avoid rounding errors. @@ -2722,11 +2720,9 @@ shaka.media.StreamingEngine = class { // use the backoff system to delay and backoff the error handling. await this.failureCallbackBackoff_.attempt(); this.destroyer_.ensureNotDestroyed(); - - const maxDisabledTime = this.getDisabledTime_(error); // Try to recover from network errors - if (error.category === shaka.util.Error.Category.NETWORK && - maxDisabledTime > 0) { + if (error.category === shaka.util.Error.Category.NETWORK) { + const maxDisabledTime = this.getDisabledTime_(error); error.handled = this.playerInterface_.disableStream( mediaState.stream, maxDisabledTime); diff --git a/lib/player.js b/lib/player.js index 3e0d215a19..a6429a309b 100644 --- a/lib/player.js +++ b/lib/player.js @@ -7227,6 +7227,10 @@ shaka.Player = class extends shaka.util.FakeEventTarget { return false; } + if (disableTime == 0) { + return false; + } + // It only makes sense to disable a stream if we have an alternative else we // end up disabling all variants. const hasAltStream = this.manifest_.variants.some((variant) => { diff --git a/test/media/streaming_engine_unit.js b/test/media/streaming_engine_unit.js index 4989005047..6a5644730a 100644 --- a/test/media/streaming_engine_unit.js +++ b/test/media/streaming_engine_unit.js @@ -2256,7 +2256,9 @@ describe('StreamingEngine', () => { onError.and.callFake((error) => { expect(error.code).toBe(shaka.util.Error.Code.HTTP_ERROR); + expect(error.handled).toBeFalsy(); }); + disableStream.and.callFake((stream, disableTime) => disableTime != 0); // Here we go! streamingEngine.switchVariant(variant); @@ -2265,7 +2267,7 @@ describe('StreamingEngine', () => { playing = true; await runTest(); - expect(disableStream).not.toHaveBeenCalled(); + expect(disableStream).toHaveBeenCalledTimes(1); }); it('always tries to recover shaka.util.Error.Code.SEGMENT_MISSING',