Path: blob/main/files/en-us/web/api/audioencoder/encode/index.md
6516 views
------{{securecontext_header}}{{APIRef("WebCodecs API")}}{{SeeCompatTable}}
The encode() method of the {{domxref("AudioEncoder")}} interface enqueues a control message to encode a given {{domxref("AudioData")}} object.
Syntax
Parameters
data: An {{domxref("AudioData")}} object.
Return value
None ({{jsxref("undefined")}}).
Exceptions
InvalidStateError{{domxref("DOMException")}}: Thrown if the {{domxref("AudioEncoder.state","state")}} is not
"configured".
{{jsxref("TypeError")}}
: Thrown if the
AudioDataobject has been transferred.
Examples
In the following example encode is passed an AudioData object.
Specifications
{{Specifications}}
Browser compatibility
{{Compat}}