AudioChannelManager

by 2 contributors:
Our volunteers haven't translated this article into עברית yet. Join us and help get the job done!

Non-standard
This feature is not on a current W3C standards track, but it is supported on the Firefox OS platform. Although implementations may change in the future and it is not supported widely across browsers, it is suitable for use in code dedicated to Firefox OS apps.

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 properties from its parent, EventTarget

AudioChannelManager.headphones Read only
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.

Example

In the following simple example, we use the navigator.mozAudioChannelManager 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.

var channelValue = 'content';

if (navigator.mozAudioChannelManager) {
  if(channelValue == 'normal') {
    navigator.mozAudioChannelManager.volumeControlChannel = 'normal';
  } else if(channelValue == 'content') {
    navigator.mozAudioChannelManager.volumeControlChannel = 'content';
  }
  console.log(navigator.mozAudioChannelManager.volumeControlChannel);
}

Note: For a complete working example, see our audio-channels-demo. Try running this on your Firefox OS device as an installed app (install it using App Manager/WebIDE) and then see what happens when you play the music and then put the app in the background, with the channel set to normal, then content.

Specifications

The AudioChannels API has no official spec at the moment; see https://wiki.mozilla.org/WebAPI/AudioChannels for implementation details, WebIDL, etc.

Browser compatibility

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
General support Not supported Not supported Not supported Not supported Not supported
Feature Android Chrome Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
General support Not supported Not supported Not supported 1.0.1 Not supported Not supported Not supported

See also

Document Tags and Contributors

Contributors to this page: fscholz, chrisdavidmills
Last updated by: fscholz,