Skip to content

Commit

Permalink
Bug 1185051 - Re-register audio channels after navigate new url
Browse files Browse the repository at this point in the history
  • Loading branch information
evanxd committed Jul 21, 2015
1 parent 2f36e9c commit 3777204
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions apps/system/js/app_window.js
Expand Up @@ -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;
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 3777204

Please sign in to comment.