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

feat: Add safeSeekEndOffset feature for live reposition #7532

Merged
merged 1 commit into from
Nov 4, 2024
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
2 changes: 2 additions & 0 deletions demo/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ shakaDemo.Config = class {
/* canBeDecimal= */ true)
.addNumberInput_('Safe Seek Offset', 'streaming.safeSeekOffset',
/* canBeDecimal= */ true)
.addNumberInput_('Safe Seek Offset', 'streaming.safeSeekEndOffset',
/* canBeDecimal= */ true)
.addNumberInput_('Stall Threshold', 'streaming.stallThreshold',
/* canBeDecimal= */ true)
.addNumberInput_('Safe Skip Distance', 'streaming.stallSkip',
Expand Down
8 changes: 8 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,7 @@ shaka.extern.LiveSyncConfiguration;
* gapJumpTimerTime: number,
* durationBackoff: number,
* safeSeekOffset: number,
* safeSeekEndOffset: number,
* stallEnabled: boolean,
* stallThreshold: number,
* stallSkip: number,
Expand Down Expand Up @@ -1666,6 +1667,13 @@ shaka.extern.LiveSyncConfiguration;
* bandwidth scenarios.
* <br>
* Defaults to <code>5</code>.
* @property {number} safeSeekEndOffset
* The amount of seconds that should be added when repositioning the playhead
* after falling out of the seakable end range. This is helpful for live
* stream with a lot of GAP. This will reposition the playback in the past
* and avoid to be block at the edge and buffer at the next GAP
* <br>
* Defaults to <code>0</code>.
* @property {boolean} stallEnabled
* When set to <code>true</code>, the stall detector logic will run. If the
* playhead stops moving for <code>stallThreshold</code> seconds, the player
Expand Down
4 changes: 3 additions & 1 deletion lib/media/playhead.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,9 @@ shaka.media.MediaSourcePlayhead = class {

if (currentTime > end) {
shaka.log.v1('Playhead past end.');
return end;
// We remove the safeSeekEndOffset of the seek end to avoid the player
// to be block at the edge in a live stream
return end - this.config_.safeSeekEndOffset;
}

if (currentTime < start) {
Expand Down
1 change: 1 addition & 0 deletions lib/util/player_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ shaka.util.PlayerConfiguration = class {
// Offset by 5 seconds since Chromecast takes a few seconds to start
// playing after a seek, even when buffered.
safeSeekOffset: 5,
safeSeekEndOffset: 0,
stallEnabled: true,
stallThreshold: 1 /* seconds */,
stallSkip: 0.1 /* seconds */,
Expand Down
Loading