Skip to content

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

feat(iFrame): Emit event when recording status changes, including errors (#7973)

Izak Glasenčnik05f3b4390df6
diff --git a/modules/API/API.js b/modules/API/API.js
index b64d06e6b2..9e9d17e506 100644
--- a/modules/API/API.js
+++ b/modules/API/API.js
@@ -1150,6 +1150,23 @@ class API {
});
}
+ /**
+ * Notify external application (if API is enabled) that recording has started or stopped.
+ *
+ * @param {boolean} on - True if recording is on, false otherwise.
+ * @param {string} mode - Stream or file.
+ * @param {string} error - Error type or null if success.
+ * @returns {void}
+ */
+ notifyRecordingStatusChanged(on: boolean, mode: string, error?: string) {
+ this._sendEvent({
+ name: 'recording-status-changed',
+ on,
+ mode,
+ error
+ });
+ }
+
/**
* Disposes the allocated resources.
*
diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js
index cc7a19fbec..9189d6f31b 100644
--- a/modules/API/external/external_api.js
+++ b/modules/API/external/external_api.js
@@ -88,6 +88,7 @@ const events = {
'password-required': 'passwordRequired',
'proxy-connection-event': 'proxyConnectionEvent',
'raise-hand-updated': 'raiseHandUpdated',
+ 'recording-status-changed': 'recordingStatusChanged',
'video-ready-to-close': 'readyToClose',
'video-conference-joined': 'videoConferenceJoined',
'video-conference-left': 'videoConferenceLeft',
diff --git a/react/features/recording/middleware.js b/react/features/recording/middleware.js
index f2e862634f..bccc491bde 100644
--- a/react/features/recording/middleware.js
+++ b/react/features/recording/middleware.js
@@ -45,6 +45,7 @@ import {
RECORDING_ON_SOUND_FILE
} from './sounds';
+declare var APP: Object;
declare var interfaceConfig: Object;
/**
@@ -181,6 +182,10 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
if (soundID) {
dispatch(playSound(soundID));
}
+
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyRecordingStatusChanged(true, mode);
+ }
} else if (updatedSessionData.status === OFF
&& (!oldSessionData || oldSessionData.status !== OFF)) {
dispatch(showStoppedRecordingNotification(
@@ -209,6 +214,10 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
dispatch(stopSound(soundOn));
dispatch(playSound(soundOff));
}
+
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyRecordingStatusChanged(false, mode);
+ }
}
}
@@ -231,11 +240,11 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
* @returns {void}
*/
function _showRecordingErrorNotification(recorderSession, dispatch) {
- const isStreamMode
- = recorderSession.getMode()
- === JitsiMeetJS.constants.recording.mode.STREAM;
+ const mode = recorderSession.getMode();
+ const error = recorderSession.getError();
+ const isStreamMode = mode === JitsiMeetJS.constants.recording.mode.STREAM;
- switch (recorderSession.getError()) {
+ switch (error) {
case JitsiMeetJS.constants.recording.error.SERVICE_UNAVAILABLE:
dispatch(showRecordingError({
descriptionKey: 'recording.unavailable',
@@ -270,4 +279,8 @@ function _showRecordingErrorNotification(recorderSession, dispatch) {
}));
break;
}
+
+ if (typeof APP !== 'undefined') {
+ APP.API.notifyRecordingStatusChanged(false, mode, error);
+ }
}