Parcourir la source

Merge pull request #995 from jitsi/ring_overlay_disable_ringing

Add interfaceConfig option for disabling ringing
j8
yanas il y a 8 ans
Parent
révision
688e71cd1b
3 fichiers modifiés avec 29 ajouts et 13 suppressions
  1. 2
    0
      interface_config.js
  2. 3
    3
      modules/UI/UI.js
  3. 24
    10
      modules/UI/ring_overlay/RingOverlay.js

+ 2
- 0
interface_config.js Voir le fichier

@@ -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 Voir le fichier

@@ -525,7 +525,7 @@ UI.start = function () {
525 525
     }
526 526
 
527 527
     if(APP.tokenData.callee) {
528
-        UI.showRingOverLay();
528
+        UI.showRingOverlay();
529 529
     }
530 530
 
531 531
     // Return true to indicate that the UI has been fully started and
@@ -1472,8 +1472,8 @@ UI.setMicrophoneButtonEnabled = function (enabled) {
1472 1472
     Toolbar.setAudioIconEnabled(enabled);
1473 1473
 };
1474 1474
 
1475
-UI.showRingOverLay = function () {
1476
-    RingOverlay.show(APP.tokenData.callee);
1475
+UI.showRingOverlay = function () {
1476
+    RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
1477 1477
     FilmStrip.toggleFilmStrip(false);
1478 1478
 };
1479 1479
 

+ 24
- 10
modules/UI/ring_overlay/RingOverlay.js Voir le fichier

@@ -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} disableRingingSound if true the ringing sound wont be played.
26 27
      */
27
-    constructor(callee) {
28
+    constructor(callee, disableRingingSound) {
28 29
         this._containerId = 'ringOverlay';
29 30
         this._audioContainerId = 'ringOverlayRinging';
30 31
         this.isRinging = true;
31 32
         this.callee = callee;
33
+        this.disableRingingSound = disableRingingSound;
32 34
         this.render();
33
-        this.audio = document.getElementById(this._audioContainerId);
34
-        this.audio.play();
35
-        this._setAudioTimeout();
35
+        if(!disableRingingSound)
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
@@ -58,8 +68,11 @@ class RingOverlay {
58 68
      * Builds and appends the ring overlay to the html document
59 69
      */
60 70
     _getHtmlStr(callee) {
61
-        let callingLabel = this.isRinging? "<p>Calling...</p>" : "";
62
-        let callerStateLabel =  this.isRinging? "" : " isn't available";
71
+        let callingLabel = this.isRinging ? "<p>Calling...</p>" : "";
72
+        let callerStateLabel =  this.isRinging ? "" : " isn't available";
73
+        let audioHTML = this.disableRingingSound ? ""
74
+            : "<audio id=\"" + this._audioContainerId
75
+                + "\" src=\"./sounds/ring.ogg\" />";
63 76
         return `
64 77
             <div id="${this._containerId}" class='ringing' >
65 78
                 <div class='ringing__content'>
@@ -69,7 +82,7 @@ class RingOverlay {
69 82
                         <p>${callee.getName()}${callerStateLabel}</p>
70 83
                     </div>
71 84
                 </div>
72
-                <audio id="${this._audioContainerId}" src="./sounds/ring.ogg" />
85
+                ${audioHTML}
73 86
             </div>`;
74 87
     }
75 88
 
@@ -86,6 +99,7 @@ class RingOverlay {
86 99
      * related to the ring overlay.
87 100
      */
88 101
     destroy() {
102
+        this.isRinging = false;
89 103
         this._stopAudio();
90 104
         this._detach();
91 105
     }
@@ -99,7 +113,6 @@ class RingOverlay {
99 113
     }
100 114
 
101 115
     _stopAudio() {
102
-        this.isRinging = false;
103 116
         if (this.interval) {
104 117
             clearInterval(this.interval);
105 118
         }
@@ -123,13 +136,14 @@ export default {
123 136
      * Shows the ring overlay for the passed callee.
124 137
      * @param callee {class User} the callee. Instance of User class from
125 138
      * TokenData.js
139
+     * @param {boolean} disableRingingSound if true the ringing sound wont be played.
126 140
      */
127
-    show(callee) {
141
+    show(callee, disableRingingSound = false) {
128 142
         if(overlay) {
129 143
             this.hide();
130 144
         }
131 145
 
132
-        overlay = new RingOverlay(callee);
146
+        overlay = new RingOverlay(callee, disableRingingSound);
133 147
         APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
134 148
             onAvatarDisplayed);
135 149
     },

Chargement…
Annuler
Enregistrer