Parcourir la source

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

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

* Fix APP access on mobile
master
Izak Glasenčnik il y a 4 ans
Parent
révision
05f3b4390d
Aucun compte lié à l'adresse e-mail de l'auteur

+ 17
- 0
modules/API/API.js Voir le fichier

@@ -1150,6 +1150,23 @@ class API {
1150 1150
         });
1151 1151
     }
1152 1152
 
1153
+    /**
1154
+     * Notify external application (if API is enabled) that recording has started or stopped.
1155
+     *
1156
+     * @param {boolean} on - True if recording is on, false otherwise.
1157
+     * @param {string} mode - Stream or file.
1158
+     * @param {string} error - Error type or null if success.
1159
+     * @returns {void}
1160
+     */
1161
+    notifyRecordingStatusChanged(on: boolean, mode: string, error?: string) {
1162
+        this._sendEvent({
1163
+            name: 'recording-status-changed',
1164
+            on,
1165
+            mode,
1166
+            error
1167
+        });
1168
+    }
1169
+
1153 1170
     /**
1154 1171
      * Disposes the allocated resources.
1155 1172
      *

+ 1
- 0
modules/API/external/external_api.js Voir le fichier

@@ -88,6 +88,7 @@ const events = {
88 88
     'password-required': 'passwordRequired',
89 89
     'proxy-connection-event': 'proxyConnectionEvent',
90 90
     'raise-hand-updated': 'raiseHandUpdated',
91
+    'recording-status-changed': 'recordingStatusChanged',
91 92
     'video-ready-to-close': 'readyToClose',
92 93
     'video-conference-joined': 'videoConferenceJoined',
93 94
     'video-conference-left': 'videoConferenceLeft',

+ 17
- 4
react/features/recording/middleware.js Voir le fichier

@@ -45,6 +45,7 @@ import {
45 45
     RECORDING_ON_SOUND_FILE
46 46
 } from './sounds';
47 47
 
48
+declare var APP: Object;
48 49
 declare var interfaceConfig: Object;
49 50
 
50 51
 /**
@@ -181,6 +182,10 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
181 182
                 if (soundID) {
182 183
                     dispatch(playSound(soundID));
183 184
                 }
185
+
186
+                if (typeof APP !== 'undefined') {
187
+                    APP.API.notifyRecordingStatusChanged(true, mode);
188
+                }
184 189
             } else if (updatedSessionData.status === OFF
185 190
                 && (!oldSessionData || oldSessionData.status !== OFF)) {
186 191
                 dispatch(showStoppedRecordingNotification(
@@ -209,6 +214,10 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
209 214
                     dispatch(stopSound(soundOn));
210 215
                     dispatch(playSound(soundOff));
211 216
                 }
217
+
218
+                if (typeof APP !== 'undefined') {
219
+                    APP.API.notifyRecordingStatusChanged(false, mode);
220
+                }
212 221
             }
213 222
         }
214 223
 
@@ -231,11 +240,11 @@ MiddlewareRegistry.register(({ dispatch, getState }) => next => action => {
231 240
  * @returns {void}
232 241
  */
233 242
 function _showRecordingErrorNotification(recorderSession, dispatch) {
234
-    const isStreamMode
235
-        = recorderSession.getMode()
236
-            === JitsiMeetJS.constants.recording.mode.STREAM;
243
+    const mode = recorderSession.getMode();
244
+    const error = recorderSession.getError();
245
+    const isStreamMode = mode === JitsiMeetJS.constants.recording.mode.STREAM;
237 246
 
238
-    switch (recorderSession.getError()) {
247
+    switch (error) {
239 248
     case JitsiMeetJS.constants.recording.error.SERVICE_UNAVAILABLE:
240 249
         dispatch(showRecordingError({
241 250
             descriptionKey: 'recording.unavailable',
@@ -270,4 +279,8 @@ function _showRecordingErrorNotification(recorderSession, dispatch) {
270 279
         }));
271 280
         break;
272 281
     }
282
+
283
+    if (typeof APP !== 'undefined') {
284
+        APP.API.notifyRecordingStatusChanged(false, mode, error);
285
+    }
273 286
 }

Chargement…
Annuler
Enregistrer