HTMLMediaElement.mozAudioChannelType
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 mozAudioChannelType
property of the HTMLMediaElement
interface can be used to set the audio channel that the sound coming from an <audio>
or
<video>
element will play in, on a Firefox OS device.
It is a non-standard property, defined in the AudioChannels API; see Using the AudioChannels API for more details.
Syntax
var player = document.createElement('audio'); var myAudioChannelType = player.mozAudioChannelType; myAudioChannelType = 'content';
Value
A DOMString
value.
Example
In the following simple example, we create an <audio>
element and two <source>
elements, give the player controls, set the mozAudioChannelType
to the value of the channelValue
variable, set the src
and type
of the sources, then put the elements in the DOM. Note that it is important to set the audio channel type before you set the audio source.
var channelValue = 'content'; function createAudio(channelValue) { var player = document.createElement('audio'); var source1 = document.createElement('source'); var source2 = document.createElement('source'); player.controls = true; player.mozAudioChannelType = channelValue; source1.src = 'audio/dragon.ogg'; source1.type = 'audio/ogg'; source2.src = 'audio/dragon.mp3'; source2.type = 'audio/mpeg'; player.appendChild(source1); player.appendChild(source2); audioContainer.appendChild(player); }
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
- App permissions for Firefox OS
- Using the AudioChannels API
navigator.mozAudioChannelManager
HTMLMediaElement
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/htmlmediaelement/mozaudiochanneltype