AudioEncoder Class
Encodes audio (https://w3c.github.io/webcodecs/#audioencoder-interface): the AudioData objects given to AudioEncoder.Encode are encoded by the codecs of BrowsingContextOptions.MediaCodecs, and the EncodedAudioChunk objects are given to the output callback with the configuration of their decoder.
public sealed class AudioEncoder : EventTarget- Inheritance
EventTargetAudioEncoder
Constructors
| Name | Description |
|---|---|
| AudioEncoder(AudioEncoderInit) | Creates an encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-audioencoder). |
AudioEncoder(AudioEncoderInit)
Codecs.csCreates an encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-audioencoder).
public AudioEncoder(AudioEncoderInit init)Properties
| Name | Description |
|---|---|
| EncodeQueueSize | Gets the number of pending encode requests. |
| OnDequeue | Gets or sets the event handler of the dequeue event (the queue size decreased). |
| State | Gets the state of the encoder. |
EncodeQueueSize
Codecs.csGets the number of pending encode requests.
public uint EncodeQueueSize { get; }OnDequeue
Codecs.csGets or sets the event handler of the dequeue event (the queue size decreased).
State
Codecs.csGets the state of the encoder.
public CodecState State { get; }Methods
| Name | Description |
|---|---|
| Close() | Closes the encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-close). |
| Configure(AudioEncoderConfig) | Configures the encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError. |
| Encode(AudioData) | Encodes audio (https://w3c.github.io/webcodecs/#dom-audioencoder-encode): a clone of the data is encoded. |
| Flush() | Encodes the pending audio (https://w3c.github.io/webcodecs/#dom-audioencoder-flush): the promise resolves once the chunks are delivered. |
| IsConfigSupported(AudioEncoderConfig) | Returns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-audioencoder-isconfigsupported). |
| Reset() | Discards the pending audio and the configuration (https://w3c.github.io/webcodecs/#dom-audioencoder-reset). |
Close()
Codecs.csCloses the encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-close).
public void Close()Configure(AudioEncoderConfig)
Codecs.csConfigures the encoder (https://w3c.github.io/webcodecs/#dom-audioencoder-configure): a configuration that the codecs do not support closes it with a NotSupportedError.
public void Configure(AudioEncoderConfig config)Parameters
configAudioEncoderConfig- The configuration.
Exceptions
TypeErrorException- The configuration is invalid.
DomException- An
InvalidStateErrorwhen the encoder is closed.
See also
Encode(AudioData)
Codecs.csEncodes audio (https://w3c.github.io/webcodecs/#dom-audioencoder-encode): a clone of the data is encoded.
Parameters
dataAudioData- The audio.
Exceptions
TypeErrorException- The data is closed.
DomException- An
InvalidStateErrorwhen the encoder is not configured.
See also
Flush()
Codecs.csEncodes the pending audio (https://w3c.github.io/webcodecs/#dom-audioencoder-flush): the promise resolves once the chunks are delivered.
public Task Flush()IsConfigSupported(AudioEncoderConfig)
Codecs.csReturns whether the codecs support a configuration (https://w3c.github.io/webcodecs/#dom-audioencoder-isconfigsupported).
public static Task<AudioEncoderSupport> IsConfigSupported(AudioEncoderConfig config)Parameters
configAudioEncoderConfig- The configuration.
Returns
Task<AudioEncoderSupport> 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.csDiscards the pending audio and the configuration (https://w3c.github.io/webcodecs/#dom-audioencoder-reset).
public void Reset()