From 17ba1a8078f82f8ba73e21bae17f91fc7ca6c782 Mon Sep 17 00:00:00 2001 From: Iragne Date: Fri, 1 Nov 2024 12:03:35 +0100 Subject: [PATCH] Add safeSeekEndOffset feature --- demo/config.js | 2 ++ externs/shaka/player.js | 8 ++++++++ lib/media/playhead.js | 4 +++- lib/util/player_configuration.js | 1 + 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/demo/config.js b/demo/config.js index 5be66e964e..aff6076266 100644 --- a/demo/config.js +++ b/demo/config.js @@ -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', diff --git a/externs/shaka/player.js b/externs/shaka/player.js index 46827fce9f..962d3b4dc9 100644 --- a/externs/shaka/player.js +++ b/externs/shaka/player.js @@ -1550,6 +1550,7 @@ shaka.extern.LiveSyncConfiguration; * gapJumpTimerTime: number, * durationBackoff: number, * safeSeekOffset: number, + * safeSeekEndOffset: number, * stallEnabled: boolean, * stallThreshold: number, * stallSkip: number, @@ -1666,6 +1667,13 @@ shaka.extern.LiveSyncConfiguration; * bandwidth scenarios. *
* Defaults to 5. + * @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 + *
+ * Defaults to 0. * @property {boolean} stallEnabled * When set to true, the stall detector logic will run. If the * playhead stops moving for stallThreshold seconds, the player diff --git a/lib/media/playhead.js b/lib/media/playhead.js index aeb230ec86..35b0a90108 100644 --- a/lib/media/playhead.js +++ b/lib/media/playhead.js @@ -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) { diff --git a/lib/util/player_configuration.js b/lib/util/player_configuration.js index 9a41f5b81c..d0fd9aa53b 100644 --- a/lib/util/player_configuration.js +++ b/lib/util/player_configuration.js @@ -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 */,