diff --git a/src/main/SubtitleVideoArea.tsx b/src/main/SubtitleVideoArea.tsx index cbf03a789..f37cd6bd4 100644 --- a/src/main/SubtitleVideoArea.tsx +++ b/src/main/SubtitleVideoArea.tsx @@ -142,6 +142,9 @@ const SubtitleVideoArea: React.FC<{ subtitleUrl={subtitleUrl} first={true} last={true} + isFullscreenPossible={false} + fullscreenPlayerIndex={undefined} + setFullscreenPlayerIndex={() => {}} selectIsPlaying={selectIsPlaying} selectIsMuted={selectIsMuted} selectCurrentlyAtInSeconds={selectCurrentlyAtInSeconds} diff --git a/src/main/VideoPlayers.tsx b/src/main/VideoPlayers.tsx index a940a259e..7e5765c1c 100644 --- a/src/main/VideoPlayers.tsx +++ b/src/main/VideoPlayers.tsx @@ -36,9 +36,11 @@ import { ActionCreatorWithPayload, AsyncThunk } from "@reduxjs/toolkit"; import { useTheme } from "../themes"; -import { backgroundBoxStyle } from "../cssStyles"; +import { backgroundBoxStyle, basicButtonStyle } from "../cssStyles"; import { BaseReactPlayerProps } from "react-player/base"; import { ErrorBox } from "@opencast/appkit"; +import { LuMaximize2, LuMinimize2 } from "react-icons/lu"; +import { isSafari } from "react-device-detect"; const VideoPlayers: React.FC<{ refs?: React.MutableRefObject<(VideoPlayerForwardRef | null)[]>, @@ -56,6 +58,7 @@ const VideoPlayers: React.FC<{ const videoCount = useAppSelector(selectVideoCount); const [videoPlayers, setVideoPlayers] = useState([]); + const [fullscreenPlayerIndex, setFullscreenPlayerIndex] = useState(undefined); const videoPlayerAreaStyle = css({ display: "flex", @@ -65,7 +68,9 @@ const VideoPlayers: React.FC<{ borderRadius: "5px", gap: "10px", - maxHeight: maxHeightInPixel + "px", + maxHeight: fullscreenPlayerIndex === undefined + ? maxHeightInPixel + "px" + : maxHeightInPixel * 2 + "px", }); // Initialize video players @@ -81,6 +86,9 @@ const VideoPlayers: React.FC<{ subtitleUrl={""} first={i === 0} last={i === videoCount - 1} + isFullscreenPossible={true} + fullscreenPlayerIndex={fullscreenPlayerIndex} + setFullscreenPlayerIndex={setFullscreenPlayerIndex} selectIsPlaying={selectIsPlaying} selectIsMuted={selectIsMuted} selectVolume={selectVolume} @@ -103,7 +111,7 @@ const VideoPlayers: React.FC<{ ); } setVideoPlayers(videoPlayers); - }, [primaryIndex, refs, videoCount, videos]); + }, [primaryIndex, refs, videoCount, videos, fullscreenPlayerIndex]); return ( @@ -125,6 +133,9 @@ interface VideoPlayerProps { subtitleUrl: string, first: boolean, last: boolean, + isFullscreenPossible: boolean, + fullscreenPlayerIndex: number | undefined, + setFullscreenPlayerIndex: (index: number | undefined) => void, selectIsPlaying: (state: RootState) => boolean, selectIsMuted: (state: RootState) => boolean, selectVolume: (state: RootState) => number, @@ -167,6 +178,9 @@ export const VideoPlayer = React.forwardRef { + if (ready && isSafari) { + const timeout = setTimeout(() => { + setVideoPlayerWrapperDisplay("flex"); + }, 10); + return () => clearTimeout(timeout); + } + }, [ready]); + + // Watch fullscreenPlayerIndex and toggle display briefly, in order for Safari to update itself! + useEffect(() => { + if (fullscreenPlayerIndex !== undefined && isSafari) { + setVideoPlayerWrapperDisplay("none"); + const timeout = setTimeout(() => { + setVideoPlayerWrapperDisplay("flex"); + }, 10); + return () => clearTimeout(timeout); + } + }, [fullscreenPlayerIndex]); + const videoPlayerWrapperStyles = css({ height: "100%", width: "100%", - display: "flex", + display: shouldHide ? "none" : videoPlayerWrapperDisplay, + + flexGrow: "1", // For single video, center! ...(first && last) && { justifyContent: "center" }, @@ -420,30 +464,55 @@ export const VideoPlayer = React.forwardRef { if (!errorState) { return (
- + {/* wrapper for positioning fullscreen button*/} +
+ + {isFullscreenPossible && + + } +
); } else {