diff --git a/.changeset/add_setting_to_enable_picture_in_picture_in_element_call.md b/.changeset/add_setting_to_enable_picture_in_picture_in_element_call.md new file mode 100644 index 00000000..521791c6 --- /dev/null +++ b/.changeset/add_setting_to_enable_picture_in_picture_in_element_call.md @@ -0,0 +1,5 @@ +--- +sable: minor +--- + +# Add setting to enable picture-in-picture in element-call diff --git a/src/app/features/call/CallView.tsx b/src/app/features/call/CallView.tsx index 485cd331..c845e80c 100644 --- a/src/app/features/call/CallView.tsx +++ b/src/app/features/call/CallView.tsx @@ -26,6 +26,8 @@ import { usePowerLevelsContext } from '$hooks/usePowerLevels'; import { useRoomName } from '$hooks/useRoomMeta'; import { useAtomValue } from 'jotai'; import { nicknamesAtom } from '$state/nicknames'; +import { settingsAtom } from '$state/settings'; +import { useSetting } from '$state/hooks/settings'; import * as css from './CallView.css'; import { CallViewUser } from './CallViewUser'; @@ -138,10 +140,25 @@ export function CallView({ room }: { room: Room }) { wait: 50, immediate: false, }); + + const [allowPipVideos] = useSetting(settingsAtom, 'allowPipVideos'); + useEffect(() => { const iframeElement = activeIframeDisplayRef?.current; const hostElement = iframeHostRef?.current; + if (allowPipVideos) { + const removeDisablePictureInPicture = (mutated: any) => { + mutated.forEach((event: any) => { + Array.from(event.target.getElementsByTagName('video')).forEach((video: any) => { + video.removeAttribute('disablepictureinpicture'); + }); + }); + }; + const pipObserver = new MutationObserver(removeDisablePictureInPicture); + pipObserver.observe(iframeElement?.contentDocument!, { subtree: true, childList: true }); + } + if (room.isCallRoom() || (callIsCurrentAndReady && iframeElement && hostElement)) { applyFixedPositioningToIframe(); @@ -172,6 +189,7 @@ export function CallView({ room }: { room: Room }) { debouncedApplyFixedPositioning, callIsCurrentAndReady, room, + allowPipVideos, ]); const handleJoinVCClick: MouseEventHandler = (evt) => { diff --git a/src/app/features/settings/cosmetics/Cosmetics.tsx b/src/app/features/settings/cosmetics/Cosmetics.tsx index d39d3a2a..0e2f555e 100644 --- a/src/app/features/settings/cosmetics/Cosmetics.tsx +++ b/src/app/features/settings/cosmetics/Cosmetics.tsx @@ -240,6 +240,23 @@ function IdentityCosmetics() { ); } +function VideoCosmetics() { + const [allowPipVideos, setPipVideos] = useSetting(settingsAtom, 'allowPipVideos'); + + return ( + + Video + + } + /> + + + ); +} + type CosmeticsProps = { requestClose: () => void; }; @@ -269,6 +286,7 @@ export function Cosmetics({ requestClose }: CosmeticsProps) { + diff --git a/src/app/state/settings.ts b/src/app/state/settings.ts index f845afa1..318485b0 100644 --- a/src/app/state/settings.ts +++ b/src/app/state/settings.ts @@ -43,6 +43,7 @@ export interface Settings { encUrlPreview: boolean; showHiddenEvents: boolean; legacyUsernameColor: boolean; + allowPipVideos: boolean; usePushNotifications: boolean; useInAppNotifications: boolean; @@ -105,6 +106,7 @@ const defaultSettings: Settings = { encUrlPreview: false, showHiddenEvents: false, legacyUsernameColor: false, + allowPipVideos: false, // Push notifications (SW/Sygnal): default on for mobile, opt-in on desktop. // In-app pill banner: default on for mobile (primary foreground alert), opt-in on desktop.