浏览代码

Merge pull request #876 from jitsi/ui-ringoverlay-stop

feat(ringoverlay): Stop ringing after 30s and change the message
master
yanas 9 年前
父节点
当前提交
f37fd15fca
共有 1 个文件被更改,包括 20 次插入7 次删除
  1. 20
    7
      modules/UI/ring_overlay/RingOverlay.js

+ 20
- 7
modules/UI/ring_overlay/RingOverlay.js 查看文件

27
     constructor(callee) {
27
     constructor(callee) {
28
         this._containerId = 'ringOverlay';
28
         this._containerId = 'ringOverlay';
29
         this._audioContainerId = 'ringOverlayRinging';
29
         this._audioContainerId = 'ringOverlayRinging';
30
-
30
+        this.isRinging = true;
31
         this.callee = callee;
31
         this.callee = callee;
32
         this.render();
32
         this.render();
33
         this.audio = document.getElementById(this._audioContainerId);
33
         this.audio = document.getElementById(this._audioContainerId);
34
         this.audio.play();
34
         this.audio.play();
35
         this._setAudioTimeout();
35
         this._setAudioTimeout();
36
+        this._timeout = setTimeout(() => {
37
+            this.destroy();
38
+            this.render();
39
+        }, 30000);
36
     }
40
     }
37
 
41
 
38
     /**
42
     /**
54
      * Builds and appends the ring overlay to the html document
58
      * Builds and appends the ring overlay to the html document
55
      */
59
      */
56
     _getHtmlStr(callee) {
60
     _getHtmlStr(callee) {
61
+        let callingLabel = this.isRinging? "<p>Calling...</p>" : "";
62
+        let callerStateLabel =  this.isRinging? "" : " isn't available";
57
         return `
63
         return `
58
             <div id="${this._containerId}" class='ringing' >
64
             <div id="${this._containerId}" class='ringing' >
59
                 <div class='ringing__content'>
65
                 <div class='ringing__content'>
60
-                    <p>Calling...</p>
66
+                    ${callingLabel}
61
                     <img class='ringing__avatar' src="${callee.getAvatarUrl()}" />
67
                     <img class='ringing__avatar' src="${callee.getAvatarUrl()}" />
62
                     <div class="ringing__caller-info">
68
                     <div class="ringing__caller-info">
63
-                        <p>${callee.getName()}</p>
69
+                        <p>${callee.getName()}${callerStateLabel}</p>
64
                     </div>
70
                     </div>
65
                 </div>
71
                 </div>
66
                 <audio id="${this._audioContainerId}" src="/sounds/ring.ogg" />
72
                 <audio id="${this._audioContainerId}" src="/sounds/ring.ogg" />
80
      * related to the ring overlay.
86
      * related to the ring overlay.
81
      */
87
      */
82
     destroy() {
88
     destroy() {
83
-        if (this.interval) {
84
-            clearInterval(this.interval);
85
-        }
86
-
89
+        this._stopAudio();
87
         this._detach();
90
         this._detach();
88
     }
91
     }
89
 
92
 
95
         $(`#${this._containerId}`).remove();
98
         $(`#${this._containerId}`).remove();
96
     }
99
     }
97
 
100
 
101
+    _stopAudio() {
102
+        this.isRinging = false;
103
+        if (this.interval) {
104
+            clearInterval(this.interval);
105
+        }
106
+        if(this._timeout) {
107
+            clearTimeout(this._timeout);
108
+        }
109
+    }
110
+
98
     /**
111
     /**
99
      * Sets the interval that is going to play the ringing sound.
112
      * Sets the interval that is going to play the ringing sound.
100
      */
113
      */

正在加载...
取消
保存