From d3038ea76586c654140a8787862b2744ab159d41 Mon Sep 17 00:00:00 2001 From: David Baker Date: Tue, 11 Sep 2018 11:31:24 +0100 Subject: [PATCH] Don't try to exit fullscreen if not fullscreen This was causing annoying exceptions on latest Chrome. Use document.fullScreenElement to detect if we're fullscreen and don't try to exit if we aren't. --- src/components/views/voip/VideoView.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/views/voip/VideoView.js b/src/components/views/voip/VideoView.js index 1820514129..d9843042ef 100644 --- a/src/components/views/voip/VideoView.js +++ b/src/components/views/voip/VideoView.js @@ -26,6 +26,15 @@ import dis from '../../../dispatcher'; import SettingsStore from "../../../settings/SettingsStore"; +function getFullScreenElement() { + return ( + document.fullscreenElement || + document.mozFullScreenElement || + document.webkitFullscreenElement || + document.msFullscreenElement + ); +} + module.exports = React.createClass({ displayName: 'VideoView', @@ -88,7 +97,7 @@ module.exports = React.createClass({ element.msRequestFullscreen ); requestMethod.call(element); - } else { + } else if (getFullScreenElement()) { const exitMethod = ( document.exitFullscreen || document.mozCancelFullScreen || @@ -108,10 +117,7 @@ module.exports = React.createClass({ const VideoFeed = sdk.getComponent('voip.VideoFeed'); // if we're fullscreen, we don't want to set a maxHeight on the video element. - const fullscreenElement = (document.fullscreenElement || - document.mozFullScreenElement || - document.webkitFullscreenElement); - const maxVideoHeight = fullscreenElement ? null : this.props.maxHeight; + const maxVideoHeight = getFullScreenElement() ? null : this.props.maxHeight; const localVideoFeedClasses = classNames("mx_VideoView_localVideoFeed", { "mx_VideoView_localVideoFeed_flipped": SettingsStore.getValue('VideoView.flipVideoHorizontally'),