Files
upstream-mirror 1d2bfcac0c
Some checks failed
Prosody Plugin Tests / test (push) Failing after 10m11s
Close stale issues and PRs / stale (push) Failing after 1s
snapshot of https://github.com/jitsi/jitsi-meet.git @ fd1749dd28f4138aa80234fc7f311b19aaffa0e7 (2026-09-15)
2026-09-15 15:56:32 +05:00

37 lines
1.1 KiB
TypeScript

import { NativeModules, Platform } from 'react-native';
import { IReduxState } from '../../app/types';
import { PIP_ENABLED } from '../../base/flags/constants';
import { getFeatureFlag } from '../../base/flags/functions';
/**
* Checks whether Picture-in-Picture is enabled.
*
* @param {Object} state - The Redux state.
* @returns {boolean} Whether PiP is enabled or not.
*/
export function isPipEnabled(state: IReduxState) {
let enabled = getFeatureFlag(state, PIP_ENABLED);
// Override flag for Android, since it might be unsupported.
if (Platform.OS === 'android' && (typeof enabled === 'undefined' || enabled)) {
enabled = NativeModules.PictureInPicture.SUPPORTED;
}
return Boolean(enabled);
}
/**
* Enabled/Disables the PictureInPicture mode in PiP native module.
*
* @param {boolean} enabled - Whether the PiP mode should be enabled.
* @returns {void}
*/
export function setPictureInPictureEnabled(enabled: boolean) {
const { PictureInPicture } = NativeModules;
if (PictureInPicture) {
PictureInPicture.setPictureInPictureEnabled(enabled);
}
}