Pārlūkot izejas kodu

Adds smart un-mute to the shared video logic

j8
yanas 9 gadus atpakaļ
vecāks
revīzija
d08e37b42b

+ 4
- 1
conference.js Parādīt failu

@@ -73,8 +73,11 @@ function getDisplayName (id) {
73 73
 /**
74 74
  * Mute or unmute local audio stream if it exists.
75 75
  * @param {boolean} muted if audio stream should be muted or unmuted.
76
+ * @param {boolean} indicates if this local audio mute was a result of user
77
+ * interaction
78
+ *
76 79
  */
77
-function muteLocalAudio (muted) {
80
+function muteLocalAudio (muted, userInteraction) {
78 81
     if (!localAudio) {
79 82
         return;
80 83
     }

+ 3
- 0
index.html Parādīt failu

@@ -124,6 +124,9 @@
124 124
                         <ul id="micMutedPopup" class="loginmenu">
125 125
                             <li data-i18n="[html]toolbar.micMutedPopup"></li>
126 126
                         </ul>
127
+                        <ul id="unableToUnmutePopup" class="loginmenu">
128
+                            <li data-i18n="[html]toolbar.unableToUnmutePopup"></li>
129
+                        </ul>
127 130
                     </a>
128 131
                     <a class="button icon-camera" id="toolbar_button_camera" data-container="body" data-toggle="popover" data-placement="bottom" shortcut="toggleVideoPopover" data-i18n="[content]toolbar.videomute" content="Start / stop camera"></a>
129 132
                     <a class="button" id="toolbar_button_record" data-container="body" data-toggle="popover" data-placement="bottom" style="display: none"></a>

+ 2
- 1
lang/main.json Parādīt failu

@@ -65,7 +65,8 @@
65 65
         "logout": "Logout",
66 66
         "dialpad": "Show dialpad",
67 67
         "sharedVideoMutedPopup": "Your shared video has been muted so<br/>that you can talk to the other participants.",
68
-        "micMutedPopup": "Your microphone has been muted so that you<br/>would fully enjoy your shared video."
68
+        "micMutedPopup": "Your microphone has been muted so that you<br/>would fully enjoy your shared video.",
69
+        "unableToUnmutePopup": "You're not able to un-mute while the shared video is on."
69 70
     },
70 71
     "bottomtoolbar": {
71 72
         "chat": "Open / close chat",

+ 8
- 0
modules/UI/UI.js Parādīt failu

@@ -331,6 +331,14 @@ function bindEvents() {
331 331
     $(window).resize(onResize);
332 332
 }
333 333
 
334
+/**
335
+ * Returns the shared document manager object.
336
+ * @return {EtherpadManager} the shared document manager object
337
+ */
338
+UI.getSharedVideoManager = function () {
339
+    return sharedVideoManager;
340
+};
341
+
334 342
 /**
335 343
  * Starts the UI module and initializes all related components.
336 344
  *

+ 41
- 52
modules/UI/shared_video/SharedVideo.js Parādīt failu

@@ -26,6 +26,24 @@ export default class SharedVideoManager {
26 26
         this.emitter = emitter;
27 27
         this.isSharedVideoShown = false;
28 28
         this.isPlayerAPILoaded = false;
29
+        this.mutedWithUserInteraction = false;
30
+    }
31
+
32
+    /**
33
+     * Indicates if the player volume is currently on.
34
+     *
35
+     * @returns {*|player|boolean}
36
+     */
37
+    isSharedVideoVolumeOn() {
38
+        return (this.player && this.player.getVolume() > 0);
39
+    }
40
+
41
+    /**
42
+     * Indicates if the local user is the owner of the shared video.
43
+     * @returns {*|boolean}
44
+     */
45
+    isSharedVideoOwner() {
46
+        return this.from && APP.conference.isLocalId(this.from);
29 47
     }
30 48
 
31 49
     /**
@@ -169,10 +187,15 @@ export default class SharedVideoManager {
169 187
 
170 188
             // let's check, if player is not muted lets mute locally
171 189
             if(event.data.volume > 0 && !event.data.muted
172
-                && !APP.conference.isLocalAudioMuted()){
173
-                self.emitter.emit(UIEvents.AUDIO_MUTED, true);
190
+                && !APP.conference.isLocalAudioMuted()) {
191
+                self.emitter.emit(UIEvents.AUDIO_MUTED, true, false);
174 192
                 self.showMicMutedPopup(true);
175 193
             }
194
+            else if (!self.mutedWithUserInteraction
195
+                        && (event.data.volume <=0 || event.data.muted)
196
+                        && APP.conference.isLocalAudioMuted()) {
197
+                self.emitter.emit(UIEvents.AUDIO_MUTED, false, false);
198
+            }
176 199
         };
177 200
 
178 201
         window.onPlayerReady = function(event) {
@@ -231,9 +254,11 @@ export default class SharedVideoManager {
231 254
             this.processTime(player, attributes, playerPaused);
232 255
 
233 256
             // lets check the volume
234
-            if (attributes.volume !== undefined &&
235
-                player.getVolume() != attributes.volume
236
-                && APP.conference.isLocalAudioMuted()) {
257
+            if (attributes.volume !== undefined
258
+                && player.getVolume() != attributes.volume
259
+                && (APP.conference.isLocalAudioMuted()
260
+                    || !this.mutedWithUserInteraction)) {
261
+
237 262
                 player.setVolume(attributes.volume);
238 263
                 console.info("Player change of volume:" + attributes.volume);
239 264
                 this.showSharedVideoMutedPopup(false);
@@ -393,17 +418,21 @@ export default class SharedVideoManager {
393 418
     /**
394 419
      * Receives events for local audio mute/unmute by local user.
395 420
      * @param muted boolena whether it is muted or not.
421
+     * @param {boolean} indicates if this mute was a result of user interaction,
422
+     * i.e. pressing the mute button or it was programatically triggerred
396 423
      */
397
-    localAudioMuted (muted) {
424
+    localAudioMuted (muted, userInteraction) {
398 425
         if(!this.player)
399 426
             return;
400 427
 
401
-        if(muted)
428
+        if (muted) {
429
+            this.mutedWithUserInteraction = userInteraction;
402 430
             return;
431
+        }
403 432
 
404 433
         // if we are un-muting and player is not muted, lets muted
405 434
         // to not pollute the conference
406
-        if(this.player.getVolume() > 0 || !this.player.isMuted()){
435
+        if (this.player.getVolume() > 0 || !this.player.isMuted()) {
407 436
             this.player.setVolume(0);
408 437
             this.showSharedVideoMutedPopup(true);
409 438
         }
@@ -415,30 +444,10 @@ export default class SharedVideoManager {
415 444
      * @param show boolean, show or hide the notification
416 445
      */
417 446
     showMicMutedPopup (show) {
418
-        var micMutedPopupSelector = $("#micMutedPopup");
419
-        if(show) {
447
+        if(show)
420 448
             this.showSharedVideoMutedPopup(false);
421 449
 
422
-            if (!micMutedPopupSelector.is(":visible"))
423
-                micMutedPopupSelector.css("display", "inline-block");
424
-
425
-            // FIXME: we need an utility method for that.
426
-            micMutedPopupSelector.fadeIn(300,
427
-                () => {micMutedPopupSelector.css({opacity: 1});}
428
-            );
429
-
430
-            setTimeout(
431
-                function () {
432
-                    micMutedPopupSelector.fadeOut(300,
433
-                        () => {micMutedPopupSelector.css({opacity: 0});}
434
-                    );
435
-                }, 5000);
436
-        }
437
-        else {
438
-            micMutedPopupSelector.fadeOut(300,
439
-                () => {micMutedPopupSelector.css({opacity: 0});}
440
-            );
441
-        }
450
+        UIUtil.animateShowElement($("#micMutedPopup"), show, 5000);
442 451
     }
443 452
 
444 453
     /**
@@ -448,30 +457,10 @@ export default class SharedVideoManager {
448 457
      * @param show boolean, show or hide the notification
449 458
      */
450 459
     showSharedVideoMutedPopup (show) {
451
-        var sharedVideoMutedPopupSelector = $("#sharedVideoMutedPopup");
452
-        if(show) {
460
+        if(show)
453 461
             this.showMicMutedPopup(false);
454 462
 
455
-            if (!sharedVideoMutedPopupSelector.is(":visible"))
456
-                sharedVideoMutedPopupSelector.css("display", "inline-block");
457
-
458
-            // FIXME: we need an utility method for that.
459
-            sharedVideoMutedPopupSelector.fadeIn(300,
460
-                () => {sharedVideoMutedPopupSelector.css({opacity: 1});}
461
-            );
462
-
463
-            setTimeout(
464
-                function () {
465
-                    sharedVideoMutedPopupSelector.fadeOut(300,
466
-                        () => {sharedVideoMutedPopupSelector.css({opacity: 0});}
467
-                    );
468
-                }, 5000);
469
-        }
470
-        else {
471
-            sharedVideoMutedPopupSelector.fadeOut(300,
472
-                () => {sharedVideoMutedPopupSelector.css({opacity: 0});}
473
-            );
474
-        }
463
+        UIUtil.animateShowElement($("#sharedVideoMutedPopup"), show, 5000);
475 464
     }
476 465
 }
477 466
 

+ 16
- 3
modules/UI/toolbars/Toolbar.js Parādīt failu

@@ -44,12 +44,25 @@ function openLinkDialog () {
44 44
 
45 45
 const buttonHandlers = {
46 46
     "toolbar_button_mute": function () {
47
+        let sharedVideoManager = APP.UI.getSharedVideoManager();
48
+
47 49
         if (APP.conference.audioMuted) {
48
-            AnalyticsAdapter.sendEvent('toolbar.audio.unmuted');
49
-            emitter.emit(UIEvents.AUDIO_MUTED, false);
50
+            // If there's a shared video with the volume "on" and we aren't
51
+            // the video owner, we warn the user
52
+            // that currently it's not possible to unmute.
53
+            if (sharedVideoManager
54
+                && sharedVideoManager.isSharedVideoVolumeOn()
55
+                && !sharedVideoManager.isSharedVideoOwner()) {
56
+                UIUtil.animateShowElement(
57
+                    $("#unableToUnmutePopup"), true, 5000);
58
+            }
59
+            else {
60
+                AnalyticsAdapter.sendEvent('toolbar.audio.unmuted');
61
+                emitter.emit(UIEvents.AUDIO_MUTED, false, true);
62
+            }
50 63
         } else {
51 64
             AnalyticsAdapter.sendEvent('toolbar.audio.muted');
52
-            emitter.emit(UIEvents.AUDIO_MUTED, true);
65
+            emitter.emit(UIEvents.AUDIO_MUTED, true, true);
53 66
         }
54 67
     },
55 68
     "toolbar_button_camera": function () {

+ 33
- 0
modules/UI/util/UIUtil.js Parādīt failu

@@ -166,6 +166,39 @@
166 166
      */
167 167
     isVisible(el) {
168 168
         return (el.offsetParent !== null);
169
+    },
170
+
171
+    /**
172
+     * Shows / hides the element given by {selector} and sets a timeout if the
173
+     * {hideDelay} is set to a value > 0.
174
+     * @param selector the jquery selector of the element to show/hide.
175
+     * @param show a {boolean} that indicates if the element should be shown or
176
+     * hidden
177
+     * @param hideDelay the value in milliseconds to wait before hiding the
178
+     * element
179
+     */
180
+    animateShowElement(selector, show, hideDelay) {
181
+        if(show) {
182
+            if (!selector.is(":visible"))
183
+                selector.css("display", "inline-block");
184
+
185
+            selector.fadeIn(300,
186
+                () => {selector.css({opacity: 1});}
187
+            );
188
+
189
+            if (hideDelay && hideDelay > 0)
190
+                setTimeout(
191
+                    function () {
192
+                        selector.fadeOut(300,
193
+                        () => {selector.css({opacity: 0});}
194
+                    );
195
+                }, hideDelay);
196
+        }
197
+        else {
198
+            selector.fadeOut(300,
199
+                () => {selector.css({opacity: 0});}
200
+            );
201
+        }
169 202
     }
170 203
 };
171 204
 

Notiek ielāde…
Atcelt
Saglabāt