feat(RingOverlay): Add interfaceConfig option for disabling ringing

This commit is contained in:
hristoterezov 2016-10-10 19:07:47 -05:00
parent d5541f612f
commit e5503deadd
3 changed files with 26 additions and 11 deletions

View File

@ -43,6 +43,8 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars
ENABLE_FEEDBACK_ANIMATION: false, ENABLE_FEEDBACK_ANIMATION: false,
DISABLE_FOCUS_INDICATOR: false, DISABLE_FOCUS_INDICATOR: false,
DISABLE_DOMINANT_SPEAKER_INDICATOR: false, DISABLE_DOMINANT_SPEAKER_INDICATOR: false,
// disables the ringing sound when the RingOverlay is shown.
DISABLE_RINGING: false,
AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.7)", AUDIO_LEVEL_PRIMARY_COLOR: "rgba(255,255,255,0.7)",
AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.4)" AUDIO_LEVEL_SECONDARY_COLOR: "rgba(255,255,255,0.4)"
}; };

View File

@ -527,7 +527,7 @@ UI.start = function () {
} }
if(APP.tokenData.callee) { if(APP.tokenData.callee) {
UI.showRingOverLay(); UI.showRingOverlay();
} }
// Return true to indicate that the UI has been fully started and // Return true to indicate that the UI has been fully started and
@ -1478,8 +1478,8 @@ UI.setMicrophoneButtonEnabled = function (enabled) {
Toolbar.setAudioIconEnabled(enabled); Toolbar.setAudioIconEnabled(enabled);
}; };
UI.showRingOverLay = function () { UI.showRingOverlay = function () {
RingOverlay.show(APP.tokenData.callee); RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING);
FilmStrip.toggleFilmStrip(false); FilmStrip.toggleFilmStrip(false);
}; };

View File

@ -23,22 +23,32 @@ function onAvatarDisplayed(shown) {
class RingOverlay { class RingOverlay {
/** /**
* @param callee instance of User class from TokenData.js * @param callee instance of User class from TokenData.js
* @param {boolean} dontPlayAudio if true the ringing sound wont be played.
*/ */
constructor(callee) { constructor(callee, dontPlayAudio) {
this._containerId = 'ringOverlay'; this._containerId = 'ringOverlay';
this._audioContainerId = 'ringOverlayRinging'; this._audioContainerId = 'ringOverlayRinging';
this.isRinging = true; this.isRinging = true;
this.callee = callee; this.callee = callee;
this.dontPlayAudio = dontPlayAudio;
this.render(); this.render();
this.audio = document.getElementById(this._audioContainerId); if(!dontPlayAudio)
this.audio.play(); this._initAudio();
this._setAudioTimeout();
this._timeout = setTimeout(() => { this._timeout = setTimeout(() => {
this.destroy(); this.destroy();
this.render(); this.render();
}, 30000); }, 30000);
} }
/**
* Initializes the audio element and setups the interval for playing it.
*/
_initAudio() {
this.audio = document.getElementById(this._audioContainerId);
this.audio.play();
this._setAudioTimeout();
}
/** /**
* Chagnes the background of the ring overlay. * Chagnes the background of the ring overlay.
* @param {boolean} solid - if true the new background will be the solid * @param {boolean} solid - if true the new background will be the solid
@ -60,6 +70,8 @@ class RingOverlay {
_getHtmlStr(callee) { _getHtmlStr(callee) {
let callingLabel = this.isRinging? "<p>Calling...</p>" : ""; let callingLabel = this.isRinging? "<p>Calling...</p>" : "";
let callerStateLabel = this.isRinging? "" : " isn't available"; let callerStateLabel = this.isRinging? "" : " isn't available";
let audioHTML = this.dontPlayAudio? "" :
`<audio id="${this._audioContainerId}" src="./sounds/ring.ogg" />`;
return ` return `
<div id="${this._containerId}" class='ringing' > <div id="${this._containerId}" class='ringing' >
<div class='ringing__content'> <div class='ringing__content'>
@ -69,7 +81,7 @@ class RingOverlay {
<p>${callee.getName()}${callerStateLabel}</p> <p>${callee.getName()}${callerStateLabel}</p>
</div> </div>
</div> </div>
<audio id="${this._audioContainerId}" src="./sounds/ring.ogg" /> ${audioHTML}
</div>`; </div>`;
} }
@ -86,6 +98,7 @@ class RingOverlay {
* related to the ring overlay. * related to the ring overlay.
*/ */
destroy() { destroy() {
this.isRinging = false;
this._stopAudio(); this._stopAudio();
this._detach(); this._detach();
} }
@ -99,7 +112,6 @@ class RingOverlay {
} }
_stopAudio() { _stopAudio() {
this.isRinging = false;
if (this.interval) { if (this.interval) {
clearInterval(this.interval); clearInterval(this.interval);
} }
@ -123,13 +135,14 @@ export default {
* Shows the ring overlay for the passed callee. * Shows the ring overlay for the passed callee.
* @param callee {class User} the callee. Instance of User class from * @param callee {class User} the callee. Instance of User class from
* TokenData.js * TokenData.js
* @param {boolean} dontPlayAudio if true the ringing sound wont be played.
*/ */
show(callee) { show(callee, dontPlayAudio = false) {
if(overlay) { if(overlay) {
this.hide(); this.hide();
} }
overlay = new RingOverlay(callee); overlay = new RingOverlay(callee, dontPlayAudio);
APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED, APP.UI.addListener(UIEvents.LARGE_VIDEO_AVATAR_DISPLAYED,
onAvatarDisplayed); onAvatarDisplayed);
}, },