Skip to content

Commit 9e94005

Browse files
authored
RSSA-1511 - Allow to set an extra offset when the player jumps a gap (#18)
* Added jumpGapsWithCeilOffset config * Added documentation * fixed compiling issue
1 parent 4ff959c commit 9e94005

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

externs/shaka/player.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,6 +786,7 @@ shaka.extern.ManifestConfiguration;
786786
* gapDetectionThreshold: number,
787787
* smallGapLimit: number,
788788
* jumpLargeGaps: boolean,
789+
* jumpGapsWithCeilOffset: number,
789790
* durationBackoff: number,
790791
* forceTransmuxTS: boolean,
791792
* safeSeekOffset: number,
@@ -850,6 +851,12 @@ shaka.extern.ManifestConfiguration;
850851
* call <code>preventDefault()</code> on the event, the Player will jump the
851852
* gap. If <code>false</code>, then the event will be raised, but the gap
852853
* will not be jumped.
854+
* @property {number} jumpGapsWithCeilOffset
855+
* This value allows to set an extra offset in case the gap jumping is not
856+
* enough to restore playback.
857+
* By default this value is <code>0</code>, on which case it will jump to
858+
* the start of the next buffer.
859+
* By setting for instance <code>1</code>, it will jump to ceil(startBuffer+1)
853860
* @property {number} durationBackoff
854861
* By default, we will not allow seeking to exactly the duration of a
855862
* presentation. This field is the number of seconds before duration we will

lib/media/gap_jumping_controller.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,12 @@ shaka.media.GapJumpingController = class {
194194
return;
195195
}
196196

197+
const jumpOffset = this.config_.jumpGapsWithCeilOffset;
198+
197199
// StreamingEngine can buffer past the seek end, but still don't allow
198200
// seeking past it.
199-
const jumpTo = buffered.start(gapIndex);
201+
let jumpTo = buffered.start(gapIndex);
202+
jumpTo = jumpOffset ? Math.ceil(jumpTo + jumpOffset) : jumpTo;
200203
const seekEnd = this.timeline_.getSeekRangeEnd();
201204
if (jumpTo >= seekEnd) {
202205
return;
@@ -236,6 +239,11 @@ shaka.media.GapJumpingController = class {
236239
shaka.log.info(
237240
'Jumping forward', jumpSize,
238241
'seconds because of gap before start time of', jumpTo);
242+
} else if (jumpOffset) {
243+
shaka.log.info(
244+
'Jumping forward', jumpSize, 'seconds because of gap starting at',
245+
buffered.end(gapIndex - 1), 'and ending at', jumpTo,
246+
'with an jumpGapsWithCeilOffset of', jumpOffset);
239247
} else {
240248
shaka.log.info(
241249
'Jumping forward', jumpSize, 'seconds because of gap starting at',

lib/util/player_configuration.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ shaka.util.PlayerConfiguration = class {
138138
gapDetectionThreshold: 0.1,
139139
smallGapLimit: 0.5,
140140
jumpLargeGaps: false,
141+
jumpGapsWithCeilOffset: 0,
141142
durationBackoff: 1,
142143
forceTransmuxTS: false,
143144
// Offset by 5 seconds since Chromecast takes a few seconds to start

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "shaka-player",
33
"description": "DASH/EME video player library",
4-
"version": "3.2.10-norigin.2",
4+
"version": "3.2.10-norigin.3",
55
"homepage": "https://github.com/shaka-project/shaka-player",
66
"author": "Google",
77
"maintainers": [

0 commit comments

Comments
 (0)