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 committed Apr 24, 2024
1 parent bf17a34 commit 2f653f1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/text/ui_text_displayer.js
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 2f653f1

Please sign in to comment.