Преглед изворни кода

Merge pull request #995 from jitsi/ring_overlay_disable_ringing

Add interfaceConfig option for disabling ringing
master
yanas пре 9 година
родитељ
комит
688e71cd1b
3 измењених фајлова са 29 додато и 13 уклоњено
  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 Прегледај датотеку

43
     ENABLE_FEEDBACK_ANIMATION: false,
43
     ENABLE_FEEDBACK_ANIMATION: false,
44
     DISABLE_FOCUS_INDICATOR: false,
44
     DISABLE_FOCUS_INDICATOR: false,
45
     DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
45
     DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
46
+    // disables the ringing sound when the RingOverlay is shown.
47
+    DISABLE_RINGING: false,
46
     AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.7)",
48
     AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.7)",
47
     AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.4)"
49
     AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.4)"
48
 };
50
 };

+ 3
- 3
modules/UI/UI.js Прегледај датотеку

525
     }
525
     }
526
 
526
 
527
     if(APP.tokenData.callee) {
527
     if(APP.tokenData.callee) {
528
-        UI.showRingOverLay();
528
+        UI.showRingOverlay();
529
     }
529
     }
530
 
530
 
531
     // Return true to indicate that the UI has been fully started and
531
     // Return true to indicate that the UI has been fully started and
1472
     Toolbar.setAudioIconEnabled(enabled);
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
     FilmStrip.toggleFilmStrip(false);
1477
     FilmStrip.toggleFilmStrip(false);
1478
 };
1478
 };
1479
 
1479
 

+ 24
- 10
modules/UI/ring_overlay/RingOverlay.js Прегледај датотеку

23
 class RingOverlay {
23
 class RingOverlay {
24
     /**
24
     /**
25
      * @param callee instance of User class from TokenData.js
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
         this._containerId = 'ringOverlay';
29
         this._containerId = 'ringOverlay';
29
         this._audioContainerId = 'ringOverlayRinging';
30
         this._audioContainerId = 'ringOverlayRinging';
30
         this.isRinging = true;
31
         this.isRinging = true;
31
         this.callee = callee;
32
         this.callee = callee;
33
+        this.disableRingingSound = disableRingingSound;
32
         this.render();
34
         this.render();
33
-        this.audio = document.getElementById(this._audioContainerId);
34
-        this.audio.play();
35
-        this._setAudioTimeout();
35
+        if(!disableRingingSound)
36
+            this._initAudio();
36
         this._timeout = setTimeout(() => {
37
         this._timeout = setTimeout(() => {
37
             this.destroy();
38
             this.destroy();
38
             this.render();
39
             this.render();
39
         }, 30000);
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
      * Chagnes the background of the ring overlay.
53
      * Chagnes the background of the ring overlay.
44
      * @param {boolean} solid - if true the new background will be the solid
54
      * @param {boolean} solid - if true the new background will be the solid
58
      * Builds and appends the ring overlay to the html document
68
      * Builds and appends the ring overlay to the html document
59
      */
69
      */
60
     _getHtmlStr(callee) {
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
         return `
76
         return `
64
             <div id="${this._containerId}" class='ringing' >
77
             <div id="${this._containerId}" class='ringing' >
65
                 <div class='ringing__content'>
78
                 <div class='ringing__content'>
69
                         <p>${callee.getName()}${callerStateLabel}</p>
82
                         <p>${callee.getName()}${callerStateLabel}</p>
70
                     </div>
83
                     </div>
71
                 </div>
84
                 </div>
72
-                <audio id="${this._audioContainerId}" src="./sounds/ring.ogg" />
85
+                ${audioHTML}
73
             </div>`;
86
             </div>`;
74
     }
87
     }
75
 
88
 
86
      * related to the ring overlay.
99
      * related to the ring overlay.
87
      */
100
      */
88
     destroy() {
101
     destroy() {
102
+        this.isRinging = false;
89
         this._stopAudio();
103
         this._stopAudio();
90
         this._detach();
104
         this._detach();
91
     }
105
     }
99
     }
113
     }
100
 
114
 
101
     _stopAudio() {
115
     _stopAudio() {
102
-        this.isRinging = false;
103
         if (this.interval) {
116
         if (this.interval) {
104
             clearInterval(this.interval);
117
             clearInterval(this.interval);
105
         }
118
         }
123
      * Shows the ring overlay for the passed callee.
136
      * Shows the ring overlay for the passed callee.
124
      * @param callee {class User} the callee. Instance of User class from
137
      * @param callee {class User} the callee. Instance of User class from
125
      * TokenData.js
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
         if(overlay) {
142
         if(overlay) {
129
             this.hide();
143
             this.hide();
130
         }
144
         }
131
 
145
 
132
-        overlay = new RingOverlay(callee);
146
+        overlay = new RingOverlay(callee, disableRingingSound);
133
         APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
147
         APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
134
             onAvatarDisplayed);
148
             onAvatarDisplayed);
135
     },
149
     },

Loading…
Откажи
Сачувај