ソースを参照

Fix recorder error and state handling

master
yanas 9年前
コミット
0736206722
4個のファイルの変更86行の追加27行の削除
  1. 9
    8
      conference.js
  2. 4
    2
      lang/main.json
  3. 32
    17
      modules/UI/recording/Recording.js
  4. 41
    0
      modules/recorder/Recorder.js

+ 9
- 8
conference.js ファイルの表示

7
 
7
 
8
 import ConnectionQuality from './modules/connectionquality/connectionquality';
8
 import ConnectionQuality from './modules/connectionquality/connectionquality';
9
 
9
 
10
+import Recorder from './modules/recorder/Recorder';
11
+
10
 import CQEvents from './service/connectionquality/CQEvents';
12
 import CQEvents from './service/connectionquality/CQEvents';
11
 import UIEvents from './service/UI/UIEvents';
13
 import UIEvents from './service/UI/UIEvents';
12
 
14
 
346
                     devices => APP.UI.onAvailableDevicesChanged(devices)
348
                     devices => APP.UI.onAvailableDevicesChanged(devices)
347
                 );
349
                 );
348
             }
350
             }
351
+            if (config.iAmRecorder)
352
+                this.recorder = new Recorder();
353
+
349
             // XXX The API will take care of disconnecting from the XMPP server
354
             // XXX The API will take care of disconnecting from the XMPP server
350
             // (and, thus, leaving the room) on unload.
355
             // (and, thus, leaving the room) on unload.
351
             return new Promise((resolve, reject) => {
356
             return new Promise((resolve, reject) => {
532
          * @param command {String} the name of the command
537
          * @param command {String} the name of the command
533
          * @param handler {Function} handler for the command
538
          * @param handler {Function} handler for the command
534
          */
539
          */
535
-            addCommandListener () {
540
+        addCommandListener () {
536
             room.addCommandListener.apply(room, arguments);
541
             room.addCommandListener.apply(room, arguments);
537
         },
542
         },
538
         /**
543
         /**
539
          * Removes command.
544
          * Removes command.
540
          * @param name {String} the name of the command.
545
          * @param name {String} the name of the command.
541
          */
546
          */
542
-            removeCommand () {
547
+        removeCommand () {
543
             room.removeCommand.apply(room, arguments);
548
             room.removeCommand.apply(room, arguments);
544
         },
549
         },
545
         /**
550
         /**
547
          * @param name {String} the name of the command.
552
          * @param name {String} the name of the command.
548
          * @param values {Object} with keys and values that will be sent.
553
          * @param values {Object} with keys and values that will be sent.
549
          */
554
          */
550
-            sendCommand () {
555
+        sendCommand () {
551
             room.sendCommand.apply(room, arguments);
556
             room.sendCommand.apply(room, arguments);
552
         },
557
         },
553
         /**
558
         /**
555
          * @param name {String} the name of the command.
560
          * @param name {String} the name of the command.
556
          * @param values {Object} with keys and values that will be sent.
561
          * @param values {Object} with keys and values that will be sent.
557
          */
562
          */
558
-            sendCommandOnce () {
563
+        sendCommandOnce () {
559
             room.sendCommandOnce.apply(room, arguments);
564
             room.sendCommandOnce.apply(room, arguments);
560
         }
565
         }
561
     },
566
     },
878
 
883
 
879
         room.on(ConferenceEvents.RECORDER_STATE_CHANGED, (status, error) => {
884
         room.on(ConferenceEvents.RECORDER_STATE_CHANGED, (status, error) => {
880
             console.log("Received recorder status change: ", status, error);
885
             console.log("Received recorder status change: ", status, error);
881
-            if(status == "error") {
882
-                console.error(error);
883
-                return;
884
-            }
885
             APP.UI.updateRecordingState(status);
886
             APP.UI.updateRecordingState(status);
886
         });
887
         });
887
 
888
 

+ 4
- 2
lang/main.json ファイルの表示

268
         "on": "Recording",
268
         "on": "Recording",
269
         "off": "Recording stopped",
269
         "off": "Recording stopped",
270
         "failedToStart": "Recording failed to start",
270
         "failedToStart": "Recording failed to start",
271
-        "buttonTooltip": "Start / stop recording"
271
+        "buttonTooltip": "Start / stop recording",
272
+        "error": "Recording failed. Please try again."
272
     },
273
     },
273
     "liveStreaming":
274
     "liveStreaming":
274
     {
275
     {
278
         "unavailable": "The live streaming service is currently unavailable. Please try again later.",
279
         "unavailable": "The live streaming service is currently unavailable. Please try again later.",
279
         "failedToStart": "Live streaming failed to start",
280
         "failedToStart": "Live streaming failed to start",
280
         "buttonTooltip": "Start / stop live stream",
281
         "buttonTooltip": "Start / stop live stream",
281
-        "streamIdRequired": "Please fill in the stream id in order to launch the live streaming."
282
+        "streamIdRequired": "Please fill in the stream id in order to launch the live streaming.",
283
+        "error": "Live streaming failed. Please try again"
282
     }
284
     }
283
 }
285
 }

+ 32
- 17
modules/UI/recording/Recording.js ファイルの表示

205
     OFF: "off",
205
     OFF: "off",
206
     AVAILABLE: "available",
206
     AVAILABLE: "available",
207
     UNAVAILABLE: "unavailable",
207
     UNAVAILABLE: "unavailable",
208
-    PENDING: "pending"
208
+    PENDING: "pending",
209
+    ERROR: "error"
209
 };
210
 };
210
 
211
 
211
 /**
212
 /**
248
             this.recordingOffKey = "liveStreaming.off";
249
             this.recordingOffKey = "liveStreaming.off";
249
             this.recordingPendingKey = "liveStreaming.pending";
250
             this.recordingPendingKey = "liveStreaming.pending";
250
             this.failedToStartKey = "liveStreaming.failedToStart";
251
             this.failedToStartKey = "liveStreaming.failedToStart";
252
+            this.recordingErrorKey = "liveStreaming.error";
251
             this.recordingButtonTooltip = "liveStreaming.buttonTooltip";
253
             this.recordingButtonTooltip = "liveStreaming.buttonTooltip";
252
         }
254
         }
253
         else {
255
         else {
256
             this.recordingOffKey = "recording.off";
258
             this.recordingOffKey = "recording.off";
257
             this.recordingPendingKey = "recording.pending";
259
             this.recordingPendingKey = "recording.pending";
258
             this.failedToStartKey = "recording.failedToStart";
260
             this.failedToStartKey = "recording.failedToStart";
261
+            this.recordingErrorKey = "recording.error";
259
             this.recordingButtonTooltip = "recording.buttonTooltip";
262
             this.recordingButtonTooltip = "recording.buttonTooltip";
260
         }
263
         }
261
 
264
 
338
      */
341
      */
339
     updateRecordingUI (recordingState) {
342
     updateRecordingUI (recordingState) {
340
         let buttonSelector = $('#toolbar_button_record');
343
         let buttonSelector = $('#toolbar_button_record');
341
-        let labelSelector = $('#recordingLabel');
342
 
344
 
343
         // TODO: handle recording state=available
345
         // TODO: handle recording state=available
344
         if (recordingState === Status.ON) {
346
         if (recordingState === Status.ON) {
346
             buttonSelector.removeClass(this.baseClass);
348
             buttonSelector.removeClass(this.baseClass);
347
             buttonSelector.addClass(this.baseClass + " active");
349
             buttonSelector.addClass(this.baseClass + " active");
348
 
350
 
349
-            labelSelector.attr("data-i18n", this.recordingOnKey);
350
-            moveToCorner(labelSelector, true, 3000);
351
-            labelSelector
352
-                .text(APP.translation.translateString(this.recordingOnKey));
353
-        } else if (recordingState === Status.OFF
354
-                    || recordingState === Status.UNAVAILABLE) {
351
+            this._updateStatusLabel(this.recordingOnKey, false);
352
+        }
353
+        else if (recordingState === Status.OFF
354
+                || recordingState === Status.UNAVAILABLE) {
355
 
355
 
356
             // We don't want to do any changes if this is
356
             // We don't want to do any changes if this is
357
             // an availability change.
357
             // an availability change.
362
             buttonSelector.removeClass(this.baseClass + " active");
362
             buttonSelector.removeClass(this.baseClass + " active");
363
             buttonSelector.addClass(this.baseClass);
363
             buttonSelector.addClass(this.baseClass);
364
 
364
 
365
-            moveToCorner(labelSelector, false);
366
             let messageKey;
365
             let messageKey;
367
             if (this.currentState === Status.PENDING)
366
             if (this.currentState === Status.PENDING)
368
                 messageKey = this.failedToStartKey;
367
                 messageKey = this.failedToStartKey;
369
             else
368
             else
370
                 messageKey = this.recordingOffKey;
369
                 messageKey = this.recordingOffKey;
371
 
370
 
372
-            labelSelector.attr("data-i18n", messageKey);
373
-            labelSelector.text(APP.translation.translateString(messageKey));
371
+            this._updateStatusLabel(messageKey, true);
374
 
372
 
375
             setTimeout(function(){
373
             setTimeout(function(){
376
                 $('#recordingLabel').css({display: "none"});
374
                 $('#recordingLabel').css({display: "none"});
381
             buttonSelector.removeClass(this.baseClass + " active");
379
             buttonSelector.removeClass(this.baseClass + " active");
382
             buttonSelector.addClass(this.baseClass);
380
             buttonSelector.addClass(this.baseClass);
383
 
381
 
384
-            moveToCorner(labelSelector, false);
385
-            labelSelector
386
-                .attr("data-i18n", this.recordingPendingKey);
387
-            labelSelector
388
-                .text(APP.translation.translateString(
389
-                    this.recordingPendingKey));
382
+            this._updateStatusLabel(this.recordingPendingKey, true);
383
+        }
384
+        else if (recordingState === Status.ERROR) {
385
+            buttonSelector.removeClass(this.baseClass + " active");
386
+            buttonSelector.addClass(this.baseClass);
387
+
388
+            this._updateStatusLabel(this.recordingErrorKey, true);
390
         }
389
         }
391
 
390
 
392
         this.currentState = recordingState;
391
         this.currentState = recordingState;
393
 
392
 
393
+        let labelSelector = $('#recordingLabel');
394
+
394
         // We don't show the label for available state.
395
         // We don't show the label for available state.
395
         if (recordingState !== Status.AVAILABLE
396
         if (recordingState !== Status.AVAILABLE
396
             && !labelSelector.is(":visible"))
397
             && !labelSelector.is(":visible"))
404
             this.eventEmitter.emit(UIEvents.RECORDING_TOGGLED,
405
             this.eventEmitter.emit(UIEvents.RECORDING_TOGGLED,
405
                                     this.predefinedToken);
406
                                     this.predefinedToken);
406
         }
407
         }
408
+    },
409
+    /**
410
+     * Updates the status label.
411
+     * @param textKey the text to show
412
+     * @param isCentered indicates if the label should be centered on the window
413
+     * or moved to the top right corner.
414
+     */
415
+    _updateStatusLabel(textKey, isCentered) {
416
+        let labelSelector = $('#recordingLabel');
417
+
418
+        moveToCorner(labelSelector, !isCentered);
419
+
420
+        labelSelector.attr("data-i18n", textKey);
421
+        labelSelector.text(APP.translation.translateString(textKey));
407
     }
422
     }
408
 };
423
 };
409
 
424
 

+ 41
- 0
modules/recorder/Recorder.js ファイルの表示

1
+/* global APP, $, config */
2
+
3
+/**
4
+ * The (name of the) command which transports the recorder info.
5
+ */
6
+const _USER_INFO_COMMAND = "userinfo";
7
+
8
+/**
9
+ * The Recorder class is meant to take care of recorder related presence
10
+ * commands.
11
+ */
12
+class Recorder {
13
+    constructor() {
14
+        if (config.iAmRecorder)
15
+            this._sendRecorderInfo();
16
+    }
17
+
18
+    /**
19
+     * Sends the information that this is a recorder through the presence.
20
+     * @private
21
+     */
22
+    _sendRecorderInfo() {
23
+        var commands = APP.conference.commands;
24
+
25
+        // XXX The "Follow Me" command represents a snapshot of all states
26
+        // which are to be followed so don't forget to removeCommand before
27
+        // sendCommand!
28
+        commands.removeCommand(_USER_INFO_COMMAND);
29
+        var self = this;
30
+        commands.sendCommand(
31
+            _USER_INFO_COMMAND,
32
+            {
33
+                attributes: {
34
+                    xmlns: 'http://jitsi.org/jitmeet/userinfo',
35
+                    robot: true
36
+                }
37
+            });
38
+    }
39
+}
40
+
41
+export default Recorder;

読み込み中…
キャンセル
保存