Skip to content

Commit 03ed6ac

Browse files
committed
Fix back buffer not being flushed when backBufferLength is set to 0 (video-dev#6781)
1 parent d25ad97 commit 03ed6ac

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/controller/buffer-controller.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1127,7 +1127,7 @@ transfer tracks: ${JSON.stringify(transferredTracks, (key, value) => (key === 'i
11271127
? config.liveBackBufferLength
11281128
: config.backBufferLength;
11291129

1130-
if (Number.isFinite(backBufferLength) && backBufferLength > 0) {
1130+
if (Number.isFinite(backBufferLength) && backBufferLength >= 0) {
11311131
const maxBackBufferLength = Math.max(backBufferLength, targetDuration);
11321132
const targetBackBufferPosition =
11331133
Math.floor(currentTime / targetDuration) * targetDuration -

tests/unit/controller/buffer-controller-operations.ts

+8
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,14 @@ describe('BufferController with attached media', function () {
617617
expect(triggerSpy).to.not.have.been.calledWith(Events.BUFFER_FLUSHING);
618618
});
619619

620+
it('should execute a remove operation if backBufferLength is set to 0', function () {
621+
hls.config.backBufferLength = 0;
622+
evokeTrimBuffers(hls);
623+
expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount(
624+
2,
625+
);
626+
});
627+
620628
it('should execute a remove operation if flushing a valid backBuffer range', function () {
621629
evokeTrimBuffers(hls);
622630
expect(triggerSpy.withArgs(Events.BUFFER_FLUSHING)).to.have.callCount(

0 commit comments

Comments
 (0)