Skip to content

Commit

Permalink
feat: Add safeSeekEndOffset feature for live reposition (#7532)
Browse files Browse the repository at this point in the history
Close #7531
  • Loading branch information
Iragne authored Nov 4, 2024
1 parent d7400fe commit 73524d0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
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

0 comments on commit 73524d0

Please sign in to comment.