fix(external-video): Youtube captions toggle

Ensures setOption and unloadModule are functions before calling.
This commit is contained in:
Arthurk12 2024-04-30 14:49:41 -03:00 committed by prlanzarin
parent 356f6331c1
commit eb29634a87

View File

@ -252,10 +252,14 @@ class VideoPlayer extends Component {
}, () => {
const { subtitlesOn } = this.state;
const { isPresenter } = this.props;
const internalPlayer = this?.player?.getInternalPlayer();
if (!internalPlayer) return;
if (!isPresenter && subtitlesOn) {
this?.player?.getInternalPlayer()?.setOption('captions', 'reload', true);
} else {
this?.player?.getInternalPlayer()?.unloadModule('captions');
if (typeof internalPlayer.setOption === 'function') {
internalPlayer.setOption('captions', 'reload', true);
}
} else if (typeof internalPlayer.unloadModule === 'function') {
internalPlayer.unloadModule('captions');
}
});
}