Selaa lähdekoodia

feat(RingOverlay): Add interfaceConfig option for disabling ringing

j8
hristoterezov 8 vuotta sitten
vanhempi
commit
e5503deadd
3 muutettua tiedostoa jossa 26 lisäystä ja 11 poistoa
  1. 2
    0
      interface_config.js
  2. 3
    3
      modules/UI/UI.js
  3. 21
    8
      modules/UI/ring_overlay/RingOverlay.js

+ 2
- 0
interface_config.js Näytä tiedosto

@@ -43,6 +43,8 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars
43 43
     ENABLE_FEEDBACK_ANIMATION: false,
44 44
     DISABLE_FOCUS_INDICATOR: false,
45 45
     DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
46
+    // disables the ringing sound when the RingOverlay is shown.
47
+    DISABLE_RINGING: false,
46 48
     AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.7)",
47 49
     AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.4)"
48 50
 };

+ 3
- 3
modules/UI/UI.js Näytä tiedosto

@@ -527,7 +527,7 @@ UI.start = function () {
527 527
     }
528 528
 
529 529
     if(APP.tokenData.callee) {
530
-        UI.showRingOverLay();
530
+        UI.showRingOverlay();
531 531
     }
532 532
 
533 533
     // Return true to indicate that the UI has been fully started and
@@ -1478,8 +1478,8 @@ UI.setMicrophoneButtonEnabled = function (enabled) {
1478 1478
     Toolbar.setAudioIconEnabled(enabled);
1479 1479
 };
1480 1480
 
1481
-UI.showRingOverLay = function () {
1482
-    RingOverlay.show(APP.tokenData.callee);
1481
+UI.showRingOverlay = function () {
1482
+    RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
1483 1483
     FilmStrip.toggleFilmStrip(false);
1484 1484
 };
1485 1485
 

+ 21
- 8
modules/UI/ring_overlay/RingOverlay.js Näytä tiedosto

@@ -23,22 +23,32 @@ function onAvatarDisplayed(shown) {
23 23
 class RingOverlay {
24 24
     /**
25 25
      * @param callee instance of User class from TokenData.js
26
+     * @param {boolean} dontPlayAudio if true the ringing sound wont be played.
26 27
      */
27
-    constructor(callee) {
28
+    constructor(callee, dontPlayAudio) {
28 29
         this._containerId = 'ringOverlay';
29 30
         this._audioContainerId = 'ringOverlayRinging';
30 31
         this.isRinging = true;
31 32
         this.callee = callee;
33
+        this.dontPlayAudio = dontPlayAudio;
32 34
         this.render();
33
-        this.audio = document.getElementById(this._audioContainerId);
34
-        this.audio.play();
35
-        this._setAudioTimeout();
35
+        if(!dontPlayAudio)
36
+            this._initAudio();
36 37
         this._timeout = setTimeout(() => {
37 38
             this.destroy();
38 39
             this.render();
39 40
         }, 30000);
40 41
     }
41 42
 
43
+    /**
44
+     * Initializes the audio element and setups the interval for playing it.
45
+     */
46
+    _initAudio() {
47
+        this.audio = document.getElementById(this._audioContainerId);
48
+        this.audio.play();
49
+        this._setAudioTimeout();
50
+    }
51
+
42 52
     /**
43 53
      * Chagnes the background of the ring overlay.
44 54
      * @param {boolean} solid - if true the new background will be the solid
@@ -60,6 +70,8 @@ class RingOverlay {
60 70
     _getHtmlStr(callee) {
61 71
         let callingLabel = this.isRinging? "<p>Calling...</p>" : "";
62 72
         let callerStateLabel =  this.isRinging? "" : " isn't available";
73
+        let audioHTML = this.dontPlayAudio? "" :
74
+            `<audio id="${this._audioContainerId}" src="./sounds/ring.ogg" />`;
63 75
         return `
64 76
             <div id="${this._containerId}" class='ringing' >
65 77
                 <div class='ringing__content'>
@@ -69,7 +81,7 @@ class RingOverlay {
69 81
                         <p>${callee.getName()}${callerStateLabel}</p>
70 82
                     </div>
71 83
                 </div>
72
-                <audio id="${this._audioContainerId}" src="./sounds/ring.ogg" />
84
+                ${audioHTML}
73 85
             </div>`;
74 86
     }
75 87
 
@@ -86,6 +98,7 @@ class RingOverlay {
86 98
      * related to the ring overlay.
87 99
      */
88 100
     destroy() {
101
+        this.isRinging = false;
89 102
         this._stopAudio();
90 103
         this._detach();
91 104
     }
@@ -99,7 +112,6 @@ class RingOverlay {
99 112
     }
100 113
 
101 114
     _stopAudio() {
102
-        this.isRinging = false;
103 115
         if (this.interval) {
104 116
             clearInterval(this.interval);
105 117
         }
@@ -123,13 +135,14 @@ export default {
123 135
      * Shows the ring overlay for the passed callee.
124 136
      * @param callee {class User} the callee. Instance of User class from
125 137
      * TokenData.js
138
+     * @param {boolean} dontPlayAudio if true the ringing sound wont be played.
126 139
      */
127
-    show(callee) {
140
+    show(callee, dontPlayAudio = false) {
128 141
         if(overlay) {
129 142
             this.hide();
130 143
         }
131 144
 
132
-        overlay = new RingOverlay(callee);
145
+        overlay = new RingOverlay(callee, dontPlayAudio);
133 146
         APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
134 147
             onAvatarDisplayed);
135 148
     },

Loading…
Peruuta
Tallenna