Skip to content

Commit

Permalink
RSSA-1511 - Allow to set an extra offset when the player jumps a gap (#…
Browse files Browse the repository at this point in the history
…18)

* Added jumpGapsWithCeilOffset config

* Added documentation

* fixed compiling issue
  • Loading branch information
guilleccc committed Mar 24, 2023
1 parent 2a29b2c commit 39f1f9e
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
7 changes: 7 additions & 0 deletions externs/shaka/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,7 @@ shaka.extern.ManifestConfiguration;
* gapDetectionThreshold: number,
* smallGapLimit: number,
* jumpLargeGaps: boolean,
* jumpGapsWithCeilOffset: number,
* durationBackoff: number,
* forceTransmuxTS: boolean,
* safeSeekOffset: number,
Expand Down Expand Up @@ -850,6 +851,12 @@ shaka.extern.ManifestConfiguration;
* call <code>preventDefault()</code> on the event, the Player will jump the
* gap. If <code>false</code>, then the event will be raised, but the gap
* will not be jumped.
* @property {number} jumpGapsWithCeilOffset
* This value allows to set an extra offset in case the gap jumping is not
* enough to restore playback.
* By default this value is <code>0</code>, on which case it will jump to
* the start of the next buffer.
* By setting for instance <code>1</code>, it will jump to ceil(startBuffer+1)
* @property {number} durationBackoff
* By default, we will not allow seeking to exactly the duration of a
* presentation. This field is the number of seconds before duration we will
Expand Down
10 changes: 9 additions & 1 deletion lib/media/gap_jumping_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,12 @@ shaka.media.GapJumpingController = class {
return;
}

const jumpOffset = this.config_.jumpGapsWithCeilOffset;

// StreamingEngine can buffer past the seek end, but still don't allow
// seeking past it.
const jumpTo = buffered.start(gapIndex);
let jumpTo = buffered.start(gapIndex);
jumpTo = jumpOffset ? Math.ceil(jumpTo + jumpOffset) : jumpTo;
const seekEnd = this.timeline_.getSeekRangeEnd();
if (jumpTo >= seekEnd) {
return;
Expand Down Expand Up @@ -234,6 +237,11 @@ shaka.media.GapJumpingController = class {
shaka.log.info(
'Jumping forward', jumpSize,
'seconds because of gap before start time of', jumpTo);
} else if (jumpOffset) {
shaka.log.info(
'Jumping forward', jumpSize, 'seconds because of gap starting at',
buffered.end(gapIndex - 1), 'and ending at', jumpTo,
'with an jumpGapsWithCeilOffset of', jumpOffset);
} else {
shaka.log.info(
'Jumping forward', jumpSize, 'seconds because of gap starting at',
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 @@ -145,6 +145,7 @@ shaka.util.PlayerConfiguration = class {
gapDetectionThreshold: 0.1,
smallGapLimit: 0.5,
jumpLargeGaps: false,
jumpGapsWithCeilOffset: 0,
durationBackoff: 1,
forceTransmuxTS: false,
// Offset by 5 seconds since Chromecast takes a few seconds to start
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "shaka-player",
"description": "DASH/EME video player library",
"version": "3.2.1-norigin.2",
"version": "3.2.1-norigin.3",
"homepage": "https://github.com/google/shaka-player",
"author": "Google",
"maintainers": [
Expand Down

0 comments on commit 39f1f9e

Please sign in to comment.