AudioDecoder Class

Decodes audio (https://w3c.github.io/webcodecs/#audiodecoder-interface): the EncodedAudioChunk objects given to AudioDecoder.Decode are decoded by the codecs of BrowsingContextOptions.MediaCodecs, and the AudioData objects are given to the output callback.

public sealed class AudioDecoder : EventTarget
Inheritance
EventTarget AudioDecoder

Constructors

NameDescription
AudioDecoder(AudioDecoderInit)Creates a decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-audiodecoder).

AudioDecoder(AudioDecoderInit)

Codecs.cs

Creates a decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-audiodecoder).

public AudioDecoder(AudioDecoderInit init)

Parameters

init AudioDecoderInit
The output and error callbacks.

See also

Properties

NameDescription
DecodeQueueSizeGets the number of pending decode requests.
OnDequeueGets or sets the event handler of the dequeue event (the queue size decreased).
StateGets the state of the decoder.

DecodeQueueSize

Codecs.cs

Gets the number of pending decode requests.

public uint DecodeQueueSize { get; }

OnDequeue

Codecs.cs

Gets or sets the event handler of the dequeue event (the queue size decreased).

public Action<Event>? OnDequeue { get; set; }

Gets the state of the decoder.

public CodecState State { get; }

Methods

NameDescription
Close()Closes the decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-close).
Configure(AudioDecoderConfig)Configures the decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.
Decode(EncodedAudioChunk)Decodes a chunk (https://w3c.github.io/webcodecs/#dom-audiodecoder-decode).
Flush()Decodes the pending chunks (https://w3c.github.io/webcodecs/#dom-audiodecoder-flush): the promise resolves once their outputs are delivered.
IsConfigSupported(AudioDecoderConfig)Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-audiodecoder-isconfigsupported).
Reset()Discards the pending chunks and the configuration (https://w3c.github.io/webcodecs/#dom-audiodecoder-reset).

Close()

Codecs.cs

Closes the decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-close).

public void Close()

Exceptions

DomException
An InvalidStateError when the decoder is closed.

See also

Configure(AudioDecoderConfig)

Codecs.cs

Configures the decoder (https://w3c.github.io/webcodecs/#dom-audiodecoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.

public void Configure(AudioDecoderConfig config)

Parameters

config AudioDecoderConfig
The configuration.

Exceptions

TypeErrorException
The configuration is invalid.
DomException
An InvalidStateError when the decoder is closed.

See also

Decode(EncodedAudioChunk)

Codecs.cs

Decodes a chunk (https://w3c.github.io/webcodecs/#dom-audiodecoder-decode).

public void Decode(EncodedAudioChunk chunk)

Parameters

chunk EncodedAudioChunk
The chunk.

Exceptions

DomException
An InvalidStateError when the decoder is not configured, a DataError when a key chunk is required.

See also

Flush()

Codecs.cs

Decodes the pending chunks (https://w3c.github.io/webcodecs/#dom-audiodecoder-flush): the promise resolves once their outputs are delivered.

public Task Flush()

IsConfigSupported(AudioDecoderConfig)

Codecs.cs

Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-audiodecoder-isconfigsupported).

public static Task<AudioDecoderSupport> IsConfigSupported(AudioDecoderConfig config)

Parameters

config AudioDecoderConfig
The configuration.

Returns

Task<AudioDecoderSupport> A task that completes with the support and the configuration with the recognized members, or fails with a TypeErrorException for an invalid configuration.

See also

Reset()

Codecs.cs

Discards the pending chunks and the configuration (https://w3c.github.io/webcodecs/#dom-audiodecoder-reset).

public void Reset()

Exceptions

DomException
An InvalidStateError when the decoder is closed.

See also