WebCodecs APIwindow_and_dedicated
The AudioEncoder() constructor creates a new AudioEncoder object with the provided init.output callback assigned as the output callback, the provided init.error callback as the error callback, and the AudioEncoder.state set to "unconfigured".
Syntax
new AudioEncoder(init)
Parameters
init- : An object containing two required callbacks.
output- : A callback which takes an EncodedAudioChunk object as the first argument, and an optional metadata object as the second. The metadata object has one member,
decoderConfigwhich has an object as its value containing: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.
description- : An ArrayBuffer, a TypedArray, or a DataView containing a sequence of codec specific bytes, commonly known as extradata.
- : A callback which takes an EncodedAudioChunk object as the first argument, and an optional metadata object as the second. The metadata object has one member,
error- : A callback which takes an Error object as its only argument.
- : An object containing two required callbacks.
Examples
In the following example an AudioEncoder is created with the two required callback functions, one to deal with the decoded frame and the other to handle errors.
const audioEncoder = new AudioEncoder({
output: processAudio,
error: onEncoderError,
});
Specifications
Browser compatibility
来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。
