Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Load the last remaining segment when the user seeks to end #3847

Merged
merged 3 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/streaming/StreamProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,14 @@ function StreamProcessor(config) {
})
.then(() => {
// Figure out the correct segment request time.
const targetTime = bufferController.getContinuousBufferTimeForTargetTime(e.seekTime);
const continuousBufferTime = bufferController.getContinuousBufferTimeForTargetTime(e.seekTime);

// If the buffer is continuous and exceeds the duration of the period we are still done buffering. We need to trigger the buffering completed event in order to start prebuffering upcoming periods again
if (!isNaN(streamInfo.duration) && isFinite(streamInfo.duration) && targetTime >= streamInfo.start + streamInfo.duration) {
if (!isNaN(continuousBufferTime) && !isNaN(streamInfo.duration) && isFinite(streamInfo.duration) && continuousBufferTime >= streamInfo.start + streamInfo.duration) {
bufferController.setIsBufferingCompleted(true);
resolve();
} else {
const targetTime = isNaN(continuousBufferTime) ? e.seekTime : continuousBufferTime;
setExplicitBufferingTime(targetTime);
bufferController.setSeekTarget(targetTime);

Expand Down Expand Up @@ -1085,7 +1086,8 @@ function StreamProcessor(config) {

function _bufferClearedForNonReplacement() {
const time = playbackController.getTime();
const targetTime = bufferController.getContinuousBufferTimeForTargetTime(time);
const continuousBufferTime = bufferController.getContinuousBufferTimeForTargetTime(time);
const targetTime = isNaN(continuousBufferTime) ? time : continuousBufferTime;

setExplicitBufferingTime(targetTime);
scheduleController.startScheduleTimer();
Expand Down
4 changes: 2 additions & 2 deletions src/streaming/controllers/BufferController.js
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ function BufferController(config) {
const ranges = sourceBufferSink.getAllBufferRanges();

if (!ranges || ranges.length === 0) {
return targetTime;
return NaN;
}

let i = 0;
Expand All @@ -989,7 +989,7 @@ function BufferController(config) {
i += 1;
}

return adjustedTime;
return adjustedTime === targetTime ? NaN : adjustedTime;

} catch (e) {

Expand Down