diff --git a/apps/system/js/app_window.js b/apps/system/js/app_window.js index 40273e52af32..33373f9b4d7b 100644 --- a/apps/system/js/app_window.js +++ b/apps/system/js/app_window.js @@ -765,8 +765,10 @@ this.browserContainer.appendChild(this.browser.element); this.iframe = this.browser.element; this.launchTime = Date.now(); + // Register audio channels for new browser frame. + this._unregisterAudioChannels(); + this._registerAudioChannels(); } - this.browser.element.src = url; }; @@ -851,16 +853,7 @@ } } - // Register audio channels. - this.audioChannels = new Map(); - var audioChannels = this.browser.element.allowedAudioChannels; - audioChannels && audioChannels.forEach((audioChannel) => { - this.audioChannels.set( - audioChannel.name, - new AudioChannelController(this, audioChannel) - ); - this.debug('Registered ' + audioChannel.name + ' audio channel'); - }); + this._registerAudioChannels(); if (this.isInputMethod) { return; @@ -896,17 +889,35 @@ this[componentName] = null; } + this._unregisterAudioChannels(); + + if (this.appChrome) { + this.appChrome.destroy(); + this.appChrome = null; + } + }; + + AppWindow.prototype._registerAudioChannels = + function aw_registerAudioChannels() { + this.audioChannels = new Map(); + var audioChannels = this.browser.element.allowedAudioChannels; + audioChannels && audioChannels.forEach((audioChannel) => { + this.audioChannels.set( + audioChannel.name, + new AudioChannelController(this, audioChannel) + ); + this.debug('Registered ' + audioChannel.name + ' audio channel'); + }); + }; + + AppWindow.prototype._unregisterAudioChannels = + function aw_unregisterAudioChannels() { if (this.audioChannels) { this.audioChannels.forEach(function(audioChannel) { audioChannel.destroy(); }); this.audioChannels = null; } - - if (this.appChrome) { - this.appChrome.destroy(); - this.appChrome = null; - } }; AppWindow.prototype._handle__localized = function aw__handle__localized() {