show controls if both calls to play fail (#1724)

This commit is contained in:
mayeaux 2022-06-24 14:52:01 +02:00 committed by GitHub
parent 7ea73c3f1b
commit 628da8bb04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -510,13 +510,29 @@ export default React.memo<Props>(function VideoJs(props: Props) {
// $FlowIssue
vjsPlayer?.muted(true);
// $FlowIssue
vjsPlayer?.play();
const mutedPlayPromise = vjsPlayer?.play();
if (mutedPlayPromise !== undefined) {
mutedPlayPromise
.then(() => {
const tapToUnmuteButton = document.querySelector('.video-js--tap-to-unmute');
// $FlowIssue
document.querySelector('.video-js--tap-to-unmute')?.style.setProperty('visibility', 'visible');
tapToUnmuteButton?.style.setProperty('visibility', 'visible');
// $FlowIssue
document
.querySelector('.video-js--tap-to-unmute')
?.style.setProperty('display', 'inline', 'important');
tapToUnmuteButton?.style.setProperty('display', 'inline', 'important');
})
.catch((error) => {
// $FlowFixMe
vjsPlayer?.addClass('vjs-paused');
// $FlowFixMe
vjsPlayer?.addClass('vjs-has-started');
// $FlowFixMe
document.querySelector('.vjs-touch-overlay')?.classList.add('show-play-toggle');
// $FlowFixMe
document.querySelector('.vjs-play-control')?.classList.add('vjs-paused');
});
}
} else {
// $FlowIssue
vjsPlayer?.bigPlayButton?.show();