Skip to content

Commit

Permalink
perf: Improve GapJumpingController times (#7921)
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad authored Jan 22, 2025
1 parent b9eabe5 commit 1b19391
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/media/gap_jumping_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ shaka.media.GapJumpingController = class {
/** @private {shaka.util.EventManager} */
this.eventManager_ = new shaka.util.EventManager();

/** @private {boolean} */
this.started_ = false;

/** @private {boolean} */
this.seekingEventReceived_ = false;

Expand Down Expand Up @@ -90,7 +93,7 @@ shaka.media.GapJumpingController = class {
*/
this.gapJumpTimer_ = new shaka.util.Timer(() => {
this.onPollGapJump_();
}).tickEvery(this.config_.gapJumpTimerTime);
});
}


Expand Down Expand Up @@ -134,16 +137,22 @@ shaka.media.GapJumpingController = class {
* @param {number} startTime
*/
onStarted(startTime) {
this.started_ = true;
if (this.video_.seeking && !this.seekingEventReceived_) {
this.seekingEventReceived_ = true;
this.startTime_ = startTime;
}
if (this.gapJumpTimer_) {
this.gapJumpTimer_.tickEvery(this.config_.gapJumpTimerTime);
}
this.onPollGapJump_();
}

/** Called when a seek has started. */
onSeeking() {
this.seekingEventReceived_ = true;
this.hadSegmentAppended_ = false;
this.onPollGapJump_();
}


Expand All @@ -167,6 +176,10 @@ shaka.media.GapJumpingController = class {
if (this.video_.readyState == 0) {
return;
}
// Don't gap jump before playback started
if (!this.started_) {
return;
}
// Do not gap jump if seeking has begun, but the seeking event has not
// yet fired for this particular seek.
if (this.video_.seeking) {
Expand Down

0 comments on commit 1b19391

Please sign in to comment.