Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mohamedkhallouq
GitHub Repository: mohamedkhallouq/content
Path: blob/main/files/en-us/web/api/audioencoder/encode/index.md
6516 views
---
title: AudioEncoder.encode() slug: Web/API/AudioEncoder/encode page-type: web-api-instance-method status: - experimental browser-compat: api.AudioEncoder.encode
---

{{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

encode(data)

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")}}

Examples

In the following example encode is passed an AudioData object.

encoder.encode(data);

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}