浏览代码

Fix recorder error and state handling

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

+ 4
- 2
lang/main.json 查看文件

@@ -268,7 +268,8 @@
268 268
         "on": "Recording",
269 269
         "off": "Recording stopped",
270 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 274
     "liveStreaming":
274 275
     {
@@ -278,6 +279,7 @@
278 279
         "unavailable": "The live streaming service is currently unavailable. Please try again later.",
279 280
         "failedToStart": "Live streaming failed to start",
280 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,7 +205,8 @@ var Status = {
205 205
     OFF: "off",
206 206
     AVAILABLE: "available",
207 207
     UNAVAILABLE: "unavailable",
208
-    PENDING: "pending"
208
+    PENDING: "pending",
209
+    ERROR: "error"
209 210
 };
210 211
 
211 212
 /**
@@ -248,6 +249,7 @@ var Recording = {
248 249
             this.recordingOffKey = "liveStreaming.off";
249 250
             this.recordingPendingKey = "liveStreaming.pending";
250 251
             this.failedToStartKey = "liveStreaming.failedToStart";
252
+            this.recordingErrorKey = "liveStreaming.error";
251 253
             this.recordingButtonTooltip = "liveStreaming.buttonTooltip";
252 254
         }
253 255
         else {
@@ -256,6 +258,7 @@ var Recording = {
256 258
             this.recordingOffKey = "recording.off";
257 259
             this.recordingPendingKey = "recording.pending";
258 260
             this.failedToStartKey = "recording.failedToStart";
261
+            this.recordingErrorKey = "recording.error";
259 262
             this.recordingButtonTooltip = "recording.buttonTooltip";
260 263
         }
261 264
 
@@ -338,7 +341,6 @@ var Recording = {
338 341
      */
339 342
     updateRecordingUI (recordingState) {
340 343
         let buttonSelector = $('#toolbar_button_record');
341
-        let labelSelector = $('#recordingLabel');
342 344
 
343 345
         // TODO: handle recording state=available
344 346
         if (recordingState === Status.ON) {
@@ -346,12 +348,10 @@ var Recording = {
346 348
             buttonSelector.removeClass(this.baseClass);
347 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 356
             // We don't want to do any changes if this is
357 357
             // an availability change.
@@ -362,15 +362,13 @@ var Recording = {
362 362
             buttonSelector.removeClass(this.baseClass + " active");
363 363
             buttonSelector.addClass(this.baseClass);
364 364
 
365
-            moveToCorner(labelSelector, false);
366 365
             let messageKey;
367 366
             if (this.currentState === Status.PENDING)
368 367
                 messageKey = this.failedToStartKey;
369 368
             else
370 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 373
             setTimeout(function(){
376 374
                 $('#recordingLabel').css({display: "none"});
@@ -381,16 +379,19 @@ var Recording = {
381 379
             buttonSelector.removeClass(this.baseClass + " active");
382 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 391
         this.currentState = recordingState;
393 392
 
393
+        let labelSelector = $('#recordingLabel');
394
+
394 395
         // We don't show the label for available state.
395 396
         if (recordingState !== Status.AVAILABLE
396 397
             && !labelSelector.is(":visible"))
@@ -404,6 +405,20 @@ var Recording = {
404 405
             this.eventEmitter.emit(UIEvents.RECORDING_TOGGLED,
405 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 查看文件

@@ -0,0 +1,41 @@
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;

正在加载...
取消
保存