From 67874045ac367063afa053de1b2d0a3631cdd964 Mon Sep 17 00:00:00 2001 From: Daniel Dominguez Date: Sun, 20 May 2018 23:03:27 -0300 Subject: [PATCH] Toggle video fullscreen on doubleclick. --- src/renderer/component/video/internal/player.jsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/renderer/component/video/internal/player.jsx b/src/renderer/component/video/internal/player.jsx index 7c55c8ddf..5ec6fc965 100644 --- a/src/renderer/component/video/internal/player.jsx +++ b/src/renderer/component/video/internal/player.jsx @@ -19,6 +19,7 @@ class VideoPlayer extends React.PureComponent { }; this.togglePlayListener = this.togglePlay.bind(this); + this.toggleFullScreenVideo = this.toggleFullScreen.bind(this); } componentWillReceiveProps(nextProps) { @@ -77,6 +78,7 @@ class VideoPlayer extends React.PureComponent { changeVolume(mediaElement.volume); }); mediaElement.volume = volume; + mediaElement.addEventListener('dblclick', this.toggleFullScreenVideo); } } @@ -112,6 +114,17 @@ class VideoPlayer extends React.PureComponent { this.props.doPause(); } + toggleFullScreen(event) { + const mediaElement = this.media.children[0]; + if (mediaElement) { + if (document.webkitIsFullScreen) { + document.webkitExitFullscreen(); + } else { + mediaElement.webkitRequestFullScreen(); + } + } + } + togglePlay(event) { // ignore all events except click and spacebar keydown, or input events in a form control if (