Skip to content

Commit

Permalink
fix: Don't update captions when video is paused (#6474)
Browse files Browse the repository at this point in the history
This avoids wasting processing resources when it is not necessary
  • Loading branch information
avelad authored and joeyparrish committed May 7, 2024
1 parent 913f5c1 commit d92c22a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/text/ui_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ shaka.text.UITextDisplayer = class {

/** @private {shaka.util.Timer} */
this.captionsTimer_ = new shaka.util.Timer(() => {
this.updateCaptions_();
if (!this.video_.paused) {
this.updateCaptions_();
}
}).tickEvery(updatePeriod);

/**
Expand All @@ -93,6 +95,10 @@ shaka.text.UITextDisplayer = class {
this.updateCaptions_(/* forceUpdate= */ true);
});

this.eventManager_.listen(this.video_, 'seeking', () => {
this.updateCaptions_(/* forceUpdate= */ true);
});

// From: https://html.spec.whatwg.org/multipage/media.html#dom-video-videowidth
// Whenever the natural width or natural height of the video changes
// (including, for example, because the selected video track was changed),
Expand Down

0 comments on commit d92c22a

Please sign in to comment.