Path: blob/main/files/en-us/web/api/audioencoder/configure/index.md
6529 views
------{{securecontext_header}}{{APIRef("WebCodecs API")}}{{SeeCompatTable}}
The configure() method of the {{domxref("AudioEncoder")}} interface enqueues a control message to configure the audio encoder for encoding chunks.
Syntax
Parameters
config: A dictionary object containing the following members:
codec: A string containing a valid codec string.
sampleRate: An integer representing the number of frame samples per second.
numberOfChannels: An integer representing the number of audio channels.
bitrate{{optional_inline}}: An integer representing the bitrate.
Return value
None ({{jsxref("undefined")}}).
Exceptions
{{jsxref("TypeError")}}
: Thrown if the provided
configis invalid.
InvalidStateError{{domxref("DOMException")}}: Thrown if the {{domxref("AudioEncoder.state","state")}} is
"closed".
NotSupportedError{{domxref("DOMException")}}: 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 {{domxref("AudioEncoder")}} and configures it with some of the available options.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}