Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

(react-native-sdk): Adds `onEnterPictureInPicture` handler prop to JitsiMeeting component

Ricardo Corrief7c1500bc074
diff --git a/react-native-sdk/index.tsx b/react-native-sdk/index.tsx
index d222dec23b..8efa9ebb77 100644
--- a/react-native-sdk/index.tsx
+++ b/react-native-sdk/index.tsx
@@ -19,6 +19,7 @@ interface IEventListeners {
onConferenceJoined?: Function;
onConferenceLeft?: Function;
onConferenceWillJoin?: Function;
+ onEnterPictureInPicture?: Function;
onParticipantJoined?: Function;
onReadyToClose?: Function;
}
@@ -101,11 +102,12 @@ export const JitsiMeeting = forwardRef((props: IAppProps, ref) => {
setAppProps({
'flags': flags,
'rnSdkHandlers': {
- onReadyToClose: eventListeners.onReadyToClose,
onConferenceJoined: eventListeners.onConferenceJoined,
onConferenceWillJoin: eventListeners.onConferenceWillJoin,
onConferenceLeft: eventListeners.onConferenceLeft,
- onParticipantJoined: eventListeners.onParticipantJoined
+ onEnterPictureInPicture: eventListeners.onEnterPictureInPicture,
+ onParticipantJoined: eventListeners.onParticipantJoined,
+ onReadyToClose: eventListeners.onReadyToClose
},
'url': urlProps,
'userInfo': userInfo
diff --git a/react/features/mobile/picture-in-picture/actions.ts b/react/features/mobile/picture-in-picture/actions.ts
index ec54a4fcf3..f3a0061d87 100644
--- a/react/features/mobile/picture-in-picture/actions.ts
+++ b/react/features/mobile/picture-in-picture/actions.ts
@@ -33,9 +33,11 @@ export function enterPictureInPicture() {
new Error('Picture-in-Picture not supported'))
: Promise.resolve();
- p.then(
- () => dispatch({ type: ENTER_PICTURE_IN_PICTURE }),
- (e: string) => logger.warn(`Error entering PiP mode: ${e}`));
+ p.catch((e: string) => logger.warn(`Error entering PiP mode: ${e}`));
+
+ // We should still dispatch ENTER_PICTURE_IN_PICTURE for cases where
+ // the external app needs to handle the event (ie. react-native-sdk)
+ p.finally(() => dispatch({ type: ENTER_PICTURE_IN_PICTURE }));
}
};
}
diff --git a/react/features/mobile/react-native-sdk/middleware.js b/react/features/mobile/react-native-sdk/middleware.js
index c808dbf508..c7bbdd3773 100644
--- a/react/features/mobile/react-native-sdk/middleware.js
+++ b/react/features/mobile/react-native-sdk/middleware.js
@@ -8,6 +8,7 @@ import { PARTICIPANT_JOINED } from '../../base/participants/actionTypes';
import MiddlewareRegistry from '../../base/redux/MiddlewareRegistry';
import { READY_TO_CLOSE } from '../external-api/actionTypes';
import { participantToParticipantInfo } from '../external-api/functions';
+import { ENTER_PICTURE_IN_PICTURE } from '../picture-in-picture/actionTypes';
import { isExternalAPIAvailable } from './functions';
@@ -41,10 +42,11 @@ const externalAPIEnabled = isExternalAPIAvailable();
rnSdkHandlers?.onParticipantJoined && rnSdkHandlers?.onParticipantJoined(participantInfo);
break;
}
+ case ENTER_PICTURE_IN_PICTURE:
+ rnSdkHandlers?.onEnterPictureInPicture && rnSdkHandlers?.onEnterPictureInPicture();
+ break;
}
-
return result;
}
);
-