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 encoder for encoding chunks.

Syntax

AudioEncoder.configure(config)

Parameters

config

A dictionary object containing the following members:

codec

A string containing 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

TypeError DOMException

Thrown if the provided config is invalid.

InvalidStateError DOMException

Thrown if the state is "closed".

NotSupportedError DOMException

Thrown if the provided config is 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

BCD tables only load in the browser