Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(pip): honour the user's choice for browser Picture-in-Picture
Hristo Terezov9b09691a0615
diff --git a/react/features/pip/constants.ts b/react/features/pip/constants.tsindex 6f2b630192..ae5aae6af0 100644--- a/react/features/pip/constants.ts+++ b/react/features/pip/constants.ts@@ -7,3 +7,10 @@ export const DEFAULT_DOCUMENT_PIP_WIDTH = 284;* Default HEIGHT for the Document Picture-in-Picture window.*/export const DEFAULT_DOCUMENT_PIP_HEIGHT = 160;++/**+ * The id under which the user's choice for browser Picture-in-Picture (the config option `pip.enableBrowserPiP`) is+ * persisted in the settings. Deliberately not the path of the config option, so that a rename of the option keeps the+ * choices users have already made.+ */+export const BROWSER_PIP_OPTION_ID = 'browserPiP';diff --git a/react/features/pip/functions.ts b/react/features/pip/functions.tsindex 9a41eab73a..af1acead81 100644--- a/react/features/pip/functions.ts+++ b/react/features/pip/functions.ts@@ -4,6 +4,7 @@ import { getAvatarColor, getInitials } from '../base/avatar/functions';import { leaveConference } from '../base/conference/actions';import { browser } from '../base/lib-jitsi-meet';import { IParticipant } from '../base/participants/types';+import { getUserSelectedConfigValue } from '../base/settings/functions.any';import { getLocalVideoTrack } from '../base/tracks/functions.any';import { getVideoTrackByParticipant } from '../base/tracks/functions.web';import { ITrack } from '../base/tracks/types';@@ -11,6 +12,7 @@ import { isTrackStreamingStatusActive } from '../connection-indicator/functions'import { isPrejoinPageVisible } from '../prejoin/functions.any';import { toggleAudioFromPiP, toggleVideoFromPiP } from './actions';+import { BROWSER_PIP_OPTION_ID } from './constants';import { isPiPEnabled } from './external-api.shared';import logger from './logger';import {@@ -83,6 +85,20 @@ export function shouldShowPiPAvatar(videoTrack: ITrack | undefined): boolean {|| (!videoTrack.local && !isTrackStreamingStatusActive(videoTrack));}+/**+ * Determines whether browser Picture-in-Picture is turned on. A value set by the config, from config.js, URL+ * parameters or the iframe API, is final. When the config leaves it unset, the choice the user saved in the settings+ * applies, and without one browser PiP stays off. Electron has its own always-on PiP flow and ignores this flag.+ *+ * @param {IReduxState} state - Redux state.+ * @returns {boolean} Whether browser Picture-in-Picture is turned on.+ */+export function isBrowserPiPTurnedOn(state: IReduxState): boolean {+ const pipConfig = state['features/base/config'].pip;++ return pipConfig?.enableBrowserPiP ?? getUserSelectedConfigValue(state, BROWSER_PIP_OPTION_ID) ?? false;+}+/*** Determines if PiP should be shown based on config and current app state.* Checks if PiP is enabled and handles prejoin page visibility.@@ -99,12 +115,11 @@ export function shouldShowPiP(state: IReduxState): boolean {return false;}- // Browser PiP is opt-in: it stays disabled unless the deployment explicitly sets- // enableBrowserPiP: true (Electron is unaffected). This authoritative default lives here- // rather than in isPiPEnabled() because the external API evaluates isPiPEnabled() against- // only the embedder-provided config, without the deployment's config.js — it must stay- // permissive when the flag is absent (see isPiPEnabled()).- if (!browser.isElectron() && pipConfig?.enableBrowserPiP !== true) {+ // Browser PiP is opt-in: it stays off unless the config or the user turns it on (Electron is+ // unaffected). This authoritative default lives here rather than in isPiPEnabled() because the+ // external API evaluates isPiPEnabled() against only the embedder-provided config, without the+ // deployment's config.js — it must stay permissive when the flag is absent (see isPiPEnabled()).+ if (!browser.isElectron() && !isBrowserPiPTurnedOn(state)) {return false;}