AudioEncoder.configure()
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The configure() method of the AudioEncoder interface enqueues a control message to configure the audio decoder for decoding chunks.
Syntax
AudioDecoder.configure(config)
Parameters
config-
A dictionary object containing the following members:
codec-
A
stringcontaining a valid codec string. -
sampleRateOptional -
An integer representing the number of frame samples per second.
-
numberOfChannelsOptional -
An integer representing the number of audio channels.
-
bitrateOptional -
An integer representing the bitrate.
Return Value
None.
Exceptions
-
TypeErrorDOMException -
Thrown if the provided
configis invalid. -
InvalidStateErrorDOMException -
Thrown if the
stateis"closed". -
NotSupportedErrorDOMException -
Thrown if the provided
configis valid but the user agent cannot provide a codec that can decode this profile.
Examples
The following example creates a new AudioEncoder and configures it with some of the available options.
const init = { output: handleOutput, error: (e) => { console.log(e.message); } }; let config = { codec: 'vp8', bitrate: 2_000_000, // 2 Mbps }; let encoder = new AudioEncoder(init); encoder.configure(config);
Specifications
| Specification |
|---|
| WebCodecs # dom-audioencoder-configure |
Browser compatibility
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
configure |
94 |
94 |
No |
No |
80 |
No |
94 |
94 |
No |
No |
No |
No |
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/AudioEncoder/configure