diff --git a/web/src/components/player/LivePlayer.tsx b/web/src/components/player/LivePlayer.tsx index a8fe5d3b1..22559105a 100644 --- a/web/src/components/player/LivePlayer.tsx +++ b/web/src/components/player/LivePlayer.tsx @@ -22,6 +22,7 @@ type LivePlayerProps = { playAudio?: boolean; micEnabled?: boolean; // only webrtc supports mic iOSCompatFullScreen?: boolean; + pip?: boolean; onClick?: () => void; }; @@ -35,6 +36,7 @@ export default function LivePlayer({ playAudio = false, micEnabled = false, iOSCompatFullScreen = false, + pip, onClick, }: LivePlayerProps) { // camera activity @@ -105,6 +107,7 @@ export default function LivePlayer({ microphoneEnabled={micEnabled} iOSCompatFullScreen={iOSCompatFullScreen} onPlaying={() => setLiveReady(true)} + pip={pip} /> ); } else if (liveMode == "mse") { @@ -116,6 +119,7 @@ export default function LivePlayer({ playbackEnabled={cameraActive} audioEnabled={playAudio} onPlaying={() => setLiveReady(true)} + pip={pip} /> ); } else { diff --git a/web/src/components/player/MsePlayer.tsx b/web/src/components/player/MsePlayer.tsx index 42ae9aab6..7c88780a8 100644 --- a/web/src/components/player/MsePlayer.tsx +++ b/web/src/components/player/MsePlayer.tsx @@ -6,6 +6,7 @@ type MSEPlayerProps = { className?: string; playbackEnabled?: boolean; audioEnabled?: boolean; + pip?: boolean; onPlaying?: () => void; }; @@ -14,6 +15,7 @@ function MSEPlayer({ className, playbackEnabled = true, audioEnabled = false, + pip = false, onPlaying, }: MSEPlayerProps) { let connectTS: number = 0; @@ -268,6 +270,16 @@ function MSEPlayer({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [playbackEnabled, onDisconnect, onConnect]); + // control pip + + useEffect(() => { + if (!videoRef.current || !pip) { + return; + } + + videoRef.current.requestPictureInPicture(); + }, [pip, videoRef]); + return (