Skip to content

Commit

Permalink
Merge pull request #608 from samvera-labs/caption-underline-588
Browse files Browse the repository at this point in the history
Fix broken captions button reference in handleCaptionChange()
  • Loading branch information
Dananji authored Aug 1, 2024
2 parents 1d8bb5c + f127f8e commit 40953fb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/components/MediaPlayer/VideoJS/VideoJSPlayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -755,19 +755,24 @@ function VideoJSPlayer({
*/
const handleCaptionChange = (subsOn) => {
let player = playerRef.current;
/**
* When subsCapsButton is not setup on Video.js initialization step, and is
* later added in updatePlayer() function player.controlBar.getChild() method
* needs to be used to access it.
*/
const subsCapsBtn = player.controlBar.getChild('subsCapsButton');
/*
For audio instances Video.js is setup to not to build the CC button
in Ramp's player control bar.
*/
if (!player.controlBar.subsCapsButton
|| !player.controlBar.subsCapsButton?.children_) {
if (subsCapsBtn == undefined || !subsCapsBtn || !subsCapsBtn?.children_) {
return;
}
if (subsOn) {
player.controlBar.subsCapsButton.children_[0].addClass('captions-on');
subsCapsBtn.children_[0].addClass('captions-on');
captionsOnRef.current = true;
} else {
player.controlBar.subsCapsButton.children_[0].removeClass('captions-on');
subsCapsBtn.children_[0].removeClass('captions-on');
captionsOnRef.current = false;
}
};
Expand Down

0 comments on commit 40953fb

Please sign in to comment.