From e5503deaddd02d88bfb5c65ddc52ef4bccddadc6 Mon Sep 17 00:00:00 2001 From: hristoterezov Date: Mon, 10 Oct 2016 19:07:47 -0500 Subject: [PATCH] feat(RingOverlay): Add interfaceConfig option for disabling ringing --- interface_config.js | 2 ++ modules/UI/UI.js | 6 +++--- modules/UI/ring_overlay/RingOverlay.js | 29 +++++++++++++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/interface_config.js b/interface_config.js index 35ddd2abd2..02cfd6fe04 100644 --- a/interface_config.js +++ b/interface_config.js @@ -43,6 +43,8 @@ var interfaceConfig = { // eslint-disable-line no-unused-vars ENABLE_FEEDBACK_ANIMATION: false, DISABLE_FOCUS_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_SECONDARY_COLOR: "rgba(255,255,255,0.4)" }; diff --git a/modules/UI/UI.js b/modules/UI/UI.js index 70678b97a8..2a2a651ee3 100644 --- a/modules/UI/UI.js +++ b/modules/UI/UI.js @@ -527,7 +527,7 @@ UI.start = function () { } if(APP.tokenData.callee) { - UI.showRingOverLay(); + UI.showRingOverlay(); } // Return true to indicate that the UI has been fully started and @@ -1478,8 +1478,8 @@ UI.setMicrophoneButtonEnabled = function (enabled) { Toolbar.setAudioIconEnabled(enabled); }; -UI.showRingOverLay = function () { - RingOverlay.show(APP.tokenData.callee); +UI.showRingOverlay = function () { + RingOverlay.show(APP.tokenData.callee, interfaceConfig.DISABLE_RINGING); FilmStrip.toggleFilmStrip(false); }; diff --git a/modules/UI/ring_overlay/RingOverlay.js b/modules/UI/ring_overlay/RingOverlay.js index 6ef174a815..87cbb0d42f 100644 --- a/modules/UI/ring_overlay/RingOverlay.js +++ b/modules/UI/ring_overlay/RingOverlay.js @@ -23,22 +23,32 @@ function onAvatarDisplayed(shown) { class RingOverlay { /** * @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._audioContainerId = 'ringOverlayRinging'; this.isRinging = true; this.callee = callee; + this.dontPlayAudio = dontPlayAudio; this.render(); - this.audio = document.getElementById(this._audioContainerId); - this.audio.play(); - this._setAudioTimeout(); + if(!dontPlayAudio) + this._initAudio(); this._timeout = setTimeout(() => { this.destroy(); this.render(); }, 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. * @param {boolean} solid - if true the new background will be the solid @@ -60,6 +70,8 @@ class RingOverlay { _getHtmlStr(callee) { let callingLabel = this.isRinging? "

Calling...

" : ""; let callerStateLabel = this.isRinging? "" : " isn't available"; + let audioHTML = this.dontPlayAudio? "" : + `