diff --git a/src/room/VideoPreview.tsx b/src/room/VideoPreview.tsx index 3efcaba10..b8ab9d83b 100644 --- a/src/room/VideoPreview.tsx +++ b/src/room/VideoPreview.tsx @@ -11,6 +11,8 @@ import { facingModeFromLocalTrack, type LocalVideoTrack } from "livekit-client"; import classNames from "classnames"; import { useTranslation } from "react-i18next"; +import { allowPipSetting, useSetting, } from "../settings/settings"; + import { TileAvatar } from "../tile/TileAvatar"; import styles from "./VideoPreview.module.css"; import { type EncryptionSystem } from "../e2ee/sharedKeyManagement"; @@ -58,6 +60,7 @@ export const VideoPreview: FC = ({ () => videoEnabled && !videoTrack, [videoEnabled, videoTrack], ); + const [allowPip] = useSetting(allowPipSetting); return (
@@ -73,7 +76,7 @@ export const VideoPreview: FC = ({ playsInline // There's no reason for this to be focusable tabIndex={-1} - disablePictureInPicture + disablePictureInPicture={!allowPip} /> {(!videoEnabled || cameraIsStarting) && ( <> diff --git a/src/settings/SettingsModal.tsx b/src/settings/SettingsModal.tsx index 2b4078aa5..e926e784a 100644 --- a/src/settings/SettingsModal.tsx +++ b/src/settings/SettingsModal.tsx @@ -24,6 +24,7 @@ import { soundEffectVolume as soundEffectVolumeSetting, backgroundBlur as backgroundBlurSetting, developerMode, + allowPipSetting, } from "./settings"; import { PreferencesSettingsTab } from "./PreferencesSettingsTab"; import { Slider } from "../Slider"; @@ -169,11 +170,33 @@ export const SettingsModal: FC = ({ ), }; + const PipSetting: React.FC = (): ReactNode => { + const [allowPip, setAllowPip] = useSetting(allowPipSetting); + + return ( + <> + + setAllowPip(e.target.checked)} + /> + + + ); + }; + const videoTab: Tab = { key: "video", name: t("common.video"), content: ( <> +
( "custom-livekit-url", null, ); + +export const allowPipSetting = new Setting( + "allow-pip", + false +); diff --git a/src/tile/MediaView.tsx b/src/tile/MediaView.tsx index f912c069f..b69718ff9 100644 --- a/src/tile/MediaView.tsx +++ b/src/tile/MediaView.tsx @@ -21,6 +21,7 @@ import { RaisedHandIndicator } from "../reactions/RaisedHandIndicator"; import { showConnectionStats as showConnectionStatsSetting, showHandRaisedTimer, + allowPipSetting, useSetting, } from "../settings/settings"; import { type ReactionOption } from "../reactions"; @@ -86,7 +87,7 @@ export const MediaView: FC = ({ const { t } = useTranslation(); const [handRaiseTimerVisible] = useSetting(showHandRaisedTimer); const [showConnectionStats] = useSetting(showConnectionStatsSetting); - + const [allowPip] = useSetting(allowPipSetting); const avatarSize = Math.round(Math.min(targetWidth, targetHeight) / 2); return ( @@ -114,7 +115,7 @@ export const MediaView: FC = ({ trackRef={video} // There's no reason for this to be focusable tabIndex={-1} - disablePictureInPicture + disablePictureInPicture={!allowPip} style={{ display: video && videoEnabled ? "block" : "none" }} data-testid="video" />