Version: Smart Feature Phone 3.0

navigator.b2g.audioChannelManager

Description#

The AudioChannelManager interface of the AudioChannels API includes features for managing your device's audio channels, including setting what channel's volume to affect when the volume buttons are pressed inside a particular app.


Methods#

Note: Inherits methods from its parent, EventTarget


Properties#

Note: Inherits methods from its parent, EventTarget

AudioChannelManager.headphones

      A boolean that indicates whether headphones are plugged into the device.

AudioChannelManager.telephonySpeaker

      A boolean that allows you to set whether the "telephony" audio channel should be played out of the device's speakers.

AudioChannelManager.volumeControlChannel

      A DOMString that allows you to set which audio channel should have its volume changed when you press the device's hardware volume controls.

Event handlers#

AudioChannelManager.onheadphoneschange

      Fired when the device's headphones are plugged in or unplugged.


Examples#

In the following simple example, we use the navigator.b2g.audioChannelManager property to access the app's AudioChannelManager object, first to do some rudimentary feature detection, and then to set value of the AudioChannelManager.volumeControlChannel property, based on a received variable.

navigator.b2g.AudioChannelManager.volumeControlChannel = 'normal'
AudioChannelClient('normal')
HTMLMediaElement.mozAudioChannelType = 'normal'
AudioContext.mozAudioChannelType = 'normal'
navigator.b2g.AudioChannelManager.volumeControlChannel = 'content'
AudioChannelClient('content')
HTMLMediaElement.mozAudioChannelType = 'content'
AudioContext.mozAudioChannelType = 'content'
navigator.b2g.AudioChannelManager.volumeControlChannel = 'notification'
AudioChannelClient('notification')
HTMLMediaElement.mozAudioChannelType = 'notification'
AudioContext.mozAudioChannelType = 'notification'
navigator.b2g.AudioChannelManager.volumeControlChannel = 'alarm'
AudioChannelClient('alarm')
HTMLMediaElement.mozAudioChannelType = 'alarm'
AudioContext.mozAudioChannelType = 'alarm'
navigator.b2g.AudioChannelManager.volumeControlChannel = 'system'
AudioChannelClient('system')
HTMLMediaElement.mozAudioChannelType = 'system'
AudioContext.mozAudioChannelType = 'system'