From c073d1b4e642c059b2b6b74a16cbb7a2097c9e9a Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 30 Dec 2023 17:41:36 +0800 Subject: [PATCH] fullscreen improvements - show lower thirds in fullscreen - fix video focus issue #543 - show play icon when paused --- src/App.jsx | 61 +++++++++++++++++++++----------- src/components/VolumeControl.jsx | 1 + 2 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 555b7699..c422b7d5 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,7 +1,7 @@ import React, { memo, useEffect, useState, useCallback, useRef, useMemo } from 'react'; -import { FaAngleLeft, FaWindowClose } from 'react-icons/fa'; +import { FaAngleLeft, FaWindowClose, FaPlay } from 'react-icons/fa'; import { MdRotate90DegreesCcw } from 'react-icons/md'; -import { AnimatePresence } from 'framer-motion'; +import { AnimatePresence, motion } from 'framer-motion'; import { ThemeProvider } from 'evergreen-ui'; import useDebounceOld from 'react-use/lib/useDebounce'; // Want to phase out this import { useDebounce } from 'use-debounce'; @@ -202,6 +202,7 @@ const App = memo(() => { }, [language]); const videoRef = useRef(); + const videoContainerRef = useRef(); const setOutputPlaybackRate = useCallback((v) => { setOutputPlaybackRateState(v); @@ -1934,7 +1935,7 @@ const App = memo(() => { console.warn('No video tag to full screen'); return; } - await screenfull.toggle(videoRef.current, { navigationUI: 'hide' }); + await screenfull.toggle(videoContainerRef.current, { navigationUI: 'hide' }); } catch (err) { console.error('Failed to toggle fullscreen', err); } @@ -2209,6 +2210,13 @@ const App = memo(() => { } }, [fileUri, usingPreviewFile, filePath, setWorking, hasVideo, hasAudio, html5ifyAndLoadWithPreferences, customOutDir, showUnsupportedFileMessage]); + const onVideoFocus = useCallback((e) => { + // prevent video element from stealing focus in fullscreen mode https://github.com/mifi/lossless-cut/issues/543#issuecomment-1868167775 + e.target.blur(); + }, []); + + const onVideoClick = useCallback(() => togglePlay(), [togglePlay]); + useEffect(() => { async function tryExportEdlFile(type) { if (!checkFileOpened()) return; @@ -2378,13 +2386,14 @@ const App = memo(() => { {/* Middle part: */} -
+
{!isFileOpened && }
{/* eslint-disable-next-line jsx-a11y/media-has-caption */} @@ -2406,7 +2417,7 @@ const App = memo(() => { {bigWaveformEnabled && } {isRotationSet && !hideCanvasPreview && ( -
+
{t('Rotation preview')} {!canvasPlayerRequired && setHideCanvasPreview(true)} />} @@ -2414,21 +2425,31 @@ const App = memo(() => { )} {isFileOpened && ( -
- - - {subtitleStreams.length > 0 && } - - {!showRightBar && ( - - )} -
+ <> +
+ + + {subtitleStreams.length > 0 && } + + {!showRightBar && ( + + )} +
+ + + {!playing && !bigWaveformEnabled && ( + + + + )} + + )} diff --git a/src/components/VolumeControl.jsx b/src/components/VolumeControl.jsx index 3387ccd9..3e9b869c 100644 --- a/src/components/VolumeControl.jsx +++ b/src/components/VolumeControl.jsx @@ -2,6 +2,7 @@ import React, { memo, useState, useCallback, useRef, useEffect } from 'react'; import { FaVolumeMute, FaVolumeUp } from 'react-icons/fa'; import { useTranslation } from 'react-i18next'; + const VolumeControl = memo(({ playbackVolume, setPlaybackVolume, usingDummyVideo }) => { const [volumeControlVisible, setVolumeControlVisible] = useState(false); const timeoutRef = useRef();