Skip to content

Commit 58d9eac

Browse files
Merge branch 'main' of github.com:videojs/http-streaming into audio-only-filter
2 parents d65bdcf + 14ac65a commit 58d9eac

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

src/playlist-controller.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,12 +1702,8 @@ export class PlaylistController extends videojs.EventTarget {
17021702

17031703
const liveEdgeDelay = Vhs.Playlist.liveEdgeDelay(this.mainPlaylistLoader_.main, media);
17041704

1705-
// Make sure our seekable end is not negative
1706-
const calculatedEnd = Math.max(0, end - liveEdgeDelay);
1707-
1708-
if (calculatedEnd < start) {
1709-
return null;
1710-
}
1705+
// Make sure our seekable end is not less than the seekable start
1706+
const calculatedEnd = Math.max(start, end - liveEdgeDelay);
17111707

17121708
return createTimeRanges([[start, calculatedEnd]]);
17131709
}

test/playlist-controller.test.js

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,70 @@ QUnit.test(
26332633
}
26342634
);
26352635

2636+
QUnit.test(
2637+
'getSeekableRange_ returns a range with an end that is never less than the start',
2638+
function(assert) {
2639+
const pc = this.playlistController;
2640+
2641+
const fakeMedia = {};
2642+
const fakePlaylistLoader = {
2643+
media() {
2644+
return fakeMedia;
2645+
}
2646+
};
2647+
2648+
// Ensure mainPlaylistLoader_.main is defined (needed by liveEdgeDelay)
2649+
pc.mainPlaylistLoader_ = { main: {} };
2650+
2651+
const originalLiveEdgeDelay = Vhs.Playlist.liveEdgeDelay;
2652+
2653+
// --- Scenario 1: liveEdgeDelay = 0 ---
2654+
// With a reliable sync info of start=10 and end=15, if liveEdgeDelay is 0 then:
2655+
// calculatedEnd = Math.max(10, 15 - 0) = 15
2656+
// Expected seekable range: [10,15]
2657+
Vhs.Playlist.liveEdgeDelay = function(main, media) {
2658+
return 0;
2659+
};
2660+
2661+
pc.syncController_.getMediaSequenceSync = function(type) {
2662+
if (type === 'main') {
2663+
return {
2664+
isReliable: true,
2665+
start: 10,
2666+
end: 15
2667+
};
2668+
}
2669+
return null;
2670+
};
2671+
2672+
let seekable = pc.getSeekableRange_(fakePlaylistLoader, 'main');
2673+
2674+
timeRangesEqual(
2675+
seekable,
2676+
createTimeRanges([[10, 15]]),
2677+
'With liveEdgeDelay 0, seekable range is [10,15]'
2678+
);
2679+
2680+
// --- Scenario 2: liveEdgeDelay large enough to force clamping ---
2681+
// With the same sync info (start=10, end=15), if liveEdgeDelay = 10 then:
2682+
// calculatedEnd = Math.max(10, 15 - 10) = Math.max(10, 5) = 10
2683+
// Expected seekable range: [10,10] (the end is clamped to start)
2684+
Vhs.Playlist.liveEdgeDelay = function(main, media) {
2685+
return 10;
2686+
};
2687+
2688+
seekable = pc.getSeekableRange_(fakePlaylistLoader, 'main');
2689+
2690+
timeRangesEqual(
2691+
seekable,
2692+
createTimeRanges([[10, 10]]),
2693+
'When liveEdgeDelay forces a negative delta, seekable range is clamped to [10,10]'
2694+
);
2695+
2696+
Vhs.Playlist.liveEdgeDelay = originalLiveEdgeDelay;
2697+
}
2698+
);
2699+
26362700
QUnit.test(
26372701
'syncInfoUpdate triggers seekablechanged when seekable is updated',
26382702
function(assert) {

0 commit comments

Comments
 (0)