|
@@ -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
|
},
|