소스 검색

feat(RingOverlay): Add interfaceConfig option for disabling ringing

j8
hristoterezov 8 년 전
부모
커밋
e5503deadd
3개의 변경된 파일26개의 추가작업 그리고 11개의 파일을 삭제
  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 파일 보기

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 파일 보기

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

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

Loading…
취소
저장