Sfoglia il codice sorgente

Merge pull request #700 from bgrozev/raise-hand2

Raise hand2
j8
yanas 9 anni fa
parent
commit
769644a63f

+ 50
- 0
conference.js Vedi File

@@ -391,6 +391,14 @@ export default {
391 391
     videoMuted: false,
392 392
     isSharingScreen: false,
393 393
     isDesktopSharingEnabled: false,
394
+    /*
395
+     * Whether the local "raisedHand" flag is on.
396
+     */
397
+    isHandRaised: false,
398
+    /*
399
+     * Whether the local participant is the dominant speaker in the conference.
400
+     */
401
+    isDominantSpeaker: false,
394 402
     /**
395 403
      * Open new connection and join to the conference.
396 404
      * @param {object} options
@@ -1009,6 +1017,16 @@ export default {
1009 1017
             APP.UI.handleLastNEndpoints(ids, enteringIds);
1010 1018
         });
1011 1019
         room.on(ConferenceEvents.DOMINANT_SPEAKER_CHANGED, (id) => {
1020
+            if (this.isLocalId(id)) {
1021
+                this.isDominantSpeaker = true;
1022
+                this.setRaisedHand(false);
1023
+            } else {
1024
+                this.isDominantSpeaker = false;
1025
+                var participant = room.getParticipantById(id);
1026
+                if (participant) {
1027
+                    APP.UI.setRaisedHandStatus(participant, false);
1028
+                }
1029
+            }
1012 1030
             APP.UI.markDominantSpeaker(id);
1013 1031
         });
1014 1032
 
@@ -1031,6 +1049,13 @@ export default {
1031 1049
             APP.UI.changeDisplayName(id, displayName);
1032 1050
         });
1033 1051
 
1052
+        room.on(ConferenceEvents.PARTICIPANT_PROPERTY_CHANGED,
1053
+                (participant, name, oldValue, newValue) => {
1054
+            if (name === "raisedHand") {
1055
+                APP.UI.setRaisedHandStatus(participant, newValue);
1056
+            }
1057
+        });
1058
+
1034 1059
         room.on(ConferenceEvents.RECORDER_STATE_CHANGED, (status, error) => {
1035 1060
             console.log("Received recorder status change: ", status, error);
1036 1061
             APP.UI.updateRecordingState(status);
@@ -1423,5 +1448,30 @@ export default {
1423 1448
                 mediaDeviceHelper.setCurrentMediaDevices(devices);
1424 1449
                 APP.UI.onAvailableDevicesChanged(devices);
1425 1450
             });
1451
+    },
1452
+
1453
+    /**
1454
+     * Toggles the local "raised hand" status, if the current state allows
1455
+     * toggling.
1456
+     */
1457
+    maybeToggleRaisedHand() {
1458
+        // If we are the dominant speaker, we don't enable "raise hand".
1459
+        if (this.isHandRaised || !this.isDominantSpeaker) {
1460
+            this.setRaisedHand(!this.isHandRaised);
1461
+        }
1462
+    },
1463
+
1464
+    /**
1465
+     * Sets the local "raised hand" status to a particular value.
1466
+     */
1467
+    setRaisedHand(raisedHand) {
1468
+        if (raisedHand !== this.isHandRaised)
1469
+        {
1470
+            this.isHandRaised = raisedHand;
1471
+            // Advertise the updated status
1472
+            room.setLocalParticipantProperty("raisedHand", raisedHand);
1473
+            // Update the view
1474
+            APP.UI.setLocalRaisedHandStatus(raisedHand);
1475
+        }
1426 1476
     }
1427 1477
 };

+ 2
- 2
css/videolayout_default.css Vedi File

@@ -310,7 +310,7 @@
310 310
     z-index: 3;
311 311
 }
312 312
 
313
-.videocontainer>span.dominantspeakerindicator {
313
+.videocontainer>span.indicator {
314 314
     bottom: 0px;
315 315
     left: 0px;
316 316
     width: 25px;
@@ -327,7 +327,7 @@
327 327
     border: 0px;
328 328
 }
329 329
 
330
-#speakerindicatoricon {
330
+#indicatoricon {
331 331
     padding-top: 5px;
332 332
 }
333 333
 

+ 3
- 1
lang/main.json Vedi File

@@ -8,6 +8,7 @@
8 8
     "participant": "Participant",
9 9
     "me": "me",
10 10
     "speaker": "Speaker",
11
+    "raisedHand": "Would like to speak",
11 12
     "defaultNickname": "ex. Jane Pink",
12 13
     "defaultLink": "e.g. __url__",
13 14
     "calling": "Calling __name__ ...",
@@ -154,7 +155,8 @@
154 155
         "grantedTo": "Moderator rights granted to __to__!",
155 156
         "grantedToUnknown": "Moderator rights granted to $t(somebody)!",
156 157
         "muted": "You have started the conversation muted.",
157
-        "mutedTitle": "You're muted!"
158
+        "mutedTitle": "You're muted!",
159
+        "raisedHand": "Would like to speak."
158 160
     },
159 161
     "dialog": {
160 162
         "kickMessage": "Ouch! You have been kicked out of the meet!",

+ 19
- 1
modules/UI/UI.js Vedi File

@@ -257,7 +257,25 @@ UI.changeDisplayName = function (id, displayName) {
257 257
 };
258 258
 
259 259
 /**
260
- * Intitialize conference UI.
260
+ * Sets the "raised hand" status for a participant.
261
+ */
262
+UI.setRaisedHandStatus = (participant, raisedHandStatus) => {
263
+    VideoLayout.setRaisedHandStatus(participant.getId(), raisedHandStatus);
264
+    if (raisedHandStatus) {
265
+        messageHandler.notify(participant.getDisplayName(), 'notify.somebody',
266
+                          'connected', 'notify.raisedHand');
267
+    }
268
+};
269
+
270
+/**
271
+ * Sets the local "raised hand" status.
272
+ */
273
+UI.setLocalRaisedHandStatus = (raisedHandStatus) => {
274
+    VideoLayout.setRaisedHandStatus(APP.conference.localId, raisedHandStatus);
275
+};
276
+
277
+/**
278
+ * Initialize conference UI.
261 279
  */
262 280
 UI.initConference = function () {
263 281
     let id = APP.conference.localId;

+ 9
- 6
modules/UI/util/MessageHandler.js Vedi File

@@ -219,16 +219,19 @@ var messageHandler = {
219 219
     },
220 220
 
221 221
     /**
222
-     * Displayes notification.
223
-     * @param displayName display name of the participant that is associated with the notification.
224
-     * @param displayNameKey the key from the language file for the display name.
222
+     * Displays a notification.
223
+     * @param displayName the display name of the participant that is
224
+     * associated with the notification.
225
+     * @param displayNameKey the key from the language file for the display
226
+     * name. Only used if displayName i not provided.
225 227
      * @param cls css class for the notification
226
-     * @param messageKey the key from the language file for the text of the message.
228
+     * @param messageKey the key from the language file for the text of the
229
+     * message.
227 230
      * @param messageArguments object with the arguments for the message.
228 231
      * @param options object with language options.
229 232
      */
230
-    notify: function(displayName, displayNameKey,
231
-                         cls, messageKey, messageArguments, options) {
233
+    notify: function(displayName, displayNameKey, cls, messageKey,
234
+                     messageArguments, options) {
232 235
 
233 236
         if(!notificationsEnabled)
234 237
             return;

+ 51
- 19
modules/UI/videolayout/SmallVideo.js Vedi File

@@ -422,37 +422,69 @@ SmallVideo.prototype.avatarChanged = function (avatarUrl) {
422 422
 };
423 423
 
424 424
 /**
425
- * Updates the Indicator for dominant speaker.
426
- *
427
- * @param isSpeaker indicates the current indicator state
425
+ * Shows or hides the dominant speaker indicator.
426
+ * @param show whether to show or hide.
428 427
  */
429
-SmallVideo.prototype.updateDominantSpeakerIndicator = function (isSpeaker) {
430
-
428
+SmallVideo.prototype.showDominantSpeakerIndicator = function (show) {
431 429
     if (!this.container) {
432 430
         console.warn( "Unable to set dominant speaker indicator - "
433 431
             + this.videoSpanId + " does not exist");
434 432
         return;
435 433
     }
436 434
 
437
-    var indicatorSpan
438
-        = $('#' + this.videoSpanId + '>span.dominantspeakerindicator');
439
-
440
-    // If we do not have an indicator for this video.
441
-    if (indicatorSpan.length <= 0) {
442
-        indicatorSpan = document.createElement('span');
435
+    var indicatorSpanId = "dominantspeakerindicator";
436
+    var indicatorSpan = this.getIndicatorSpan(indicatorSpanId);
443 437
 
444
-        indicatorSpan.innerHTML
445
-            = "<i id='speakerindicatoricon' class='fa fa-bullhorn'></i>";
446
-        indicatorSpan.className = 'dominantspeakerindicator';
438
+    indicatorSpan.innerHTML
439
+        = "<i id='indicatoricon' class='fa fa-bullhorn'></i>";
440
+    // adds a tooltip
441
+    UIUtil.setTooltip(indicatorSpan, "speaker", "left");
442
+    APP.translation.translateElement($(indicatorSpan));
447 443
 
448
-        $('#' + this.videoSpanId)[0].appendChild(indicatorSpan);
444
+    $(indicatorSpan).css("visibility", show ? "visible" : "hidden");
445
+};
449 446
 
450
-        // adds a tooltip
451
-        UIUtil.setTooltip(indicatorSpan, "speaker", "left");
452
-        APP.translation.translateElement($(indicatorSpan));
447
+/**
448
+ * Shows or hides the raised hand indicator.
449
+ * @param show whether to show or hide.
450
+ */
451
+SmallVideo.prototype.showRaisedHandIndicator = function (show) {
452
+    if (!this.container) {
453
+        console.warn( "Unable to raised hand indication - "
454
+            + this.videoSpanId + " does not exist");
455
+        return;
453 456
     }
454 457
 
455
-    $(indicatorSpan).css("visibility", isSpeaker ? "visible" : "hidden");
458
+    var indicatorSpanId = "raisehandindicator";
459
+    var indicatorSpan = this.getIndicatorSpan(indicatorSpanId);
460
+
461
+    indicatorSpan.style.background = "#D6D61E";
462
+    indicatorSpan.innerHTML
463
+        = "<i id='indicatoricon' class='fa fa-hand-paper-o'></i>";
464
+
465
+    // adds a tooltip
466
+    UIUtil.setTooltip(indicatorSpan, "raisedHand", "left");
467
+    APP.translation.translateElement($(indicatorSpan));
468
+
469
+    $(indicatorSpan).css("visibility", show ? "visible" : "hidden");
470
+};
471
+
472
+/**
473
+ * Gets (creating if necessary) the "indicator" span for this SmallVideo
474
+  identified by an ID.
475
+ */
476
+SmallVideo.prototype.getIndicatorSpan = function(id) {
477
+    var indicatorSpan;
478
+    var spans = $(`#${this.videoSpanId}>[id=${id}`);
479
+    if (spans.length <= 0) {
480
+        indicatorSpan = document.createElement('span');
481
+        indicatorSpan.id = id;
482
+        indicatorSpan.className = "indicator";
483
+        $('#' + this.videoSpanId)[0].appendChild(indicatorSpan);
484
+    } else {
485
+        indicatorSpan = spans[0];
486
+    }
487
+    return indicatorSpan;
456 488
 };
457 489
 
458 490
 export default SmallVideo;

+ 17
- 5
modules/UI/videolayout/VideoLayout.js Vedi File

@@ -562,6 +562,18 @@ var VideoLayout = {
562 562
         }
563 563
     },
564 564
 
565
+    /**
566
+     * Sets the "raised hand" status for a participant identified by 'id'.
567
+     */
568
+    setRaisedHandStatus(id, raisedHandStatus) {
569
+        var video
570
+            = APP.conference.isLocalId(id)
571
+                ? localVideoThumbnail : remoteVideos[id];
572
+        if (video) {
573
+            video.showRaisedHandIndicator(raisedHandStatus);
574
+        }
575
+    },
576
+
565 577
     /**
566 578
      * On dominant speaker changed event.
567 579
      */
@@ -576,10 +588,10 @@ var VideoLayout = {
576 588
         if (APP.conference.isLocalId(id)) {
577 589
             if(oldSpeakerRemoteVideo)
578 590
             {
579
-                oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);
580
-                localVideoThumbnail.updateDominantSpeakerIndicator(true);
591
+                oldSpeakerRemoteVideo.showDominantSpeakerIndicator(false);
581 592
                 currentDominantSpeaker = null;
582 593
             }
594
+            localVideoThumbnail.showDominantSpeakerIndicator(true);
583 595
             return;
584 596
         }
585 597
 
@@ -589,12 +601,12 @@ var VideoLayout = {
589 601
         }
590 602
 
591 603
         // Update the current dominant speaker.
592
-        remoteVideo.updateDominantSpeakerIndicator(true);
593
-        localVideoThumbnail.updateDominantSpeakerIndicator(false);
604
+        remoteVideo.showDominantSpeakerIndicator(true);
605
+        localVideoThumbnail.showDominantSpeakerIndicator(false);
594 606
 
595 607
         // let's remove the indications from the remote video if any
596 608
         if (oldSpeakerRemoteVideo) {
597
-            oldSpeakerRemoteVideo.updateDominantSpeakerIndicator(false);
609
+            oldSpeakerRemoteVideo.showDominantSpeakerIndicator(false);
598 610
         }
599 611
         currentDominantSpeaker = id;
600 612
 

+ 7
- 0
modules/keyboardshortcut/keyboardshortcut.js Vedi File

@@ -40,6 +40,13 @@ function initShortcutHandlers() {
40 40
                 APP.conference.toggleAudioMuted();
41 41
             }
42 42
         },
43
+        82: {
44
+            character: "R",
45
+            function: function() {
46
+                APP.conference.maybeToggleRaisedHand();
47
+            }
48
+
49
+        },
43 50
         84: {
44 51
             character: "T",
45 52
             function: function() {

Loading…
Annulla
Salva