Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Make UITextDisplayer constructor backward compatible #6532

Merged
merged 2 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/text/ui_text_displayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,16 @@ shaka.text.UITextDisplayer = class {

this.videoContainer_.appendChild(this.textContainer_);

/** @private {number} */
const updatePeriod = (config && config.captionsUpdatePeriod) ?
avelad marked this conversation as resolved.
Show resolved Hide resolved
config.captionsUpdatePeriod : 0.25;

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

/**
* Maps cues to cue elements. Specifically points out the wrapper element of
Expand Down
7 changes: 7 additions & 0 deletions test/text/ui_text_displayer_unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -615,4 +615,11 @@ describe('UITextDisplayer', () => {

expect(videoContainer.childNodes.length).toBe(0);
});

it('Backward compatible UITextDisplayer constructor', () => {
// The third argument to UITextDisplayer constructor is new in v4.8.0.
// Test without, to support existing applications.
/** @suppress {checkTypes} */
textDisplayer = new shaka.text.UITextDisplayer(video, videoContainer);
});
});