The headphones read-only property of the AudioChannelManager interface returns a Boolean that indicates whether headphones are plugged into the device. A true value means that headphone are plugged in; false means they aren't.


var myHeadphonesValue = navigator.mozAudioChannelManager.headphones;


A Boolean value


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 create an anonymous function that runs when the AudioChannelManager.onheadphoneschange event handler fires (when the headphones are plugged in or unplugged). In this function, we test to see if AudioChannelManager.headphones returns true, then give the user a notification to tell them the result.

if (navigator.mozAudioChannelManager) {
  navigator.mozAudioChannelManager.onheadphoneschange = function() {
    if(navigator.mozAudioChannelManager.headphones == true) {
      var notification = new Notification('Headphones plugged in!');
    } else {
      var notification = new Notification('Headphones unplugged!');

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. You should also try plugging in and unplugging some headphones.


The AudioChannels API has no official spec at the moment; see for implementation details, WebIDL, etc.

Browser compatibility

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

See also


© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.

API audio Audio AudioChannelManager AudioChannels Firefox OS headphones Non-standard Property Reference