You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Proposal of mozBrowser1 APIs for Audio Channel Management v0.0.3
Properties
mozBrowser.allowedAudioChannels: List of audio channels allowed to play. Implement this like DOMTokenList { 0: "class1", 1: "class2", 2: "class3", length: 3, add: function, remove: function, toggle: function, contains: function }2.
mozBrowser.allowedAudioChannels.volume: 0 to 1, set/get volumes of all allowed audio channels.
Methods
mozBrowser.allowedAudioChannels.add(): Allow a channel to play.
mozBrowser.allowedAudioChannels.remove(): Deny a channel to play.
Not must have
mozBrowser.allowedAudioChannels.toggle(): Toggles a channel to play or deny.
mozBrowser.allowedAudioChannels.contains(): Checks if it allowed a specific channel.
Events
mozaudiochannelchange: Sent when audio channel changes.
mozaudiochannelchange
Properties
Detail
channel: A new audio channel app would like to play.
varaudioChannelManager=newAudioChannelManager();// When a new app is opened, add it into AudioChannelManager.audioChannelManager.register(newApp);
functionAudioChannelManager(){this._playingApps=[];}AudioChannelManager.prototype={// A list of mozBrowser elements._playingApps: null,register: function(appElement){appElement.addEventListener('mozaudiochannelchange',function(evt){varchannel=evt.detail.channel;if(this.isAllowed(channel)){varplayingApps=this._playingApps;playingApps.forEach(function(ele){// Deny all channels.varallowedAudioChannels=ele.allowedAudioChannels;Array.prototype.forEach.call(allowedAudioChannels,function(channel){allowedAudioChannels.remove(channel);});});playingApps=[];appElement.allowedAudioChannels.add(channel);playingApps.push(appElement);}});},isAllowed: function(audioChannel){// Compete with `_playingApps`.}};
Still has no idea to handle the loop issue, even we have the above APIs.