diff --git a/src/controller/buffer-controller.ts b/src/controller/buffer-controller.ts index 8b8b2b8d6f1..40c7902e80a 100755 --- a/src/controller/buffer-controller.ts +++ b/src/controller/buffer-controller.ts @@ -1127,7 +1127,7 @@ transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'i ? config.liveBackBufferLength : config.backBufferLength; - if (Number.isFinite(backBufferLength) && backBufferLength > 0) { + if (Number.isFinite(backBufferLength) && backBufferLength >= 0) { const maxBackBufferLength = Math.max(backBufferLength, targetDuration); const targetBackBufferPosition = Math.floor(currentTime / targetDuration) * targetDuration - diff --git a/tests/unit/controller/buffer-controller-operations.ts b/tests/unit/controller/buffer-controller-operations.ts index 433b591885e..75ed73369c4 100644 --- a/tests/unit/controller/buffer-controller-operations.ts +++ b/tests/unit/controller/buffer-controller-operations.ts @@ -617,6 +617,14 @@ describe('BufferController with attached media', function () { expect(triggerSpy).to.not.have.been.calledWith(Events.BUFFER_FLUSHING); }); + it('should execute a remove operation if backBufferLength is set to 0', function () { + hls.config.backBufferLength = 0; + evokeTrimBuffers(hls); + expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount( + 2, + ); + }); + it('should execute a remove operation if flushing a valid backBuffer range', function () { evokeTrimBuffers(hls); expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount(