AudioWorkletNode: processorerror event

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{ APIRef("Web Audio API") }}{{SecureContext_Header}}

The processorerror event fires when the underlying {{domxref("AudioWorkletProcessor")}} behind the node throws an exception in its constructor, the {{domxref("AudioWorkletProcessor.process", "process")}} method, or any user-defined class method.

Once an exception is thrown, the processor (and thus the node) will output silence throughout its lifetime.

Syntax

Use the event name in {{domxref("EventTarget/addEventListener", "addEventListener()")}}:

js-nolint
addEventListener("processorerror", (event) => { })

Alternatively, assign to the event handler property of the interface:

js-nolint
onprocessorerror = (event) => { }

Event type

A generic {{domxref("Event")}}.

Examples

To be informed when the processor throws an exception, you can add a handler to your {{domxref("AudioWorkletNode")}} instance using {{domxref("EventTarget.addEventListener", "addEventListener()")}}, like this:

js
whiteNoiseNode.addEventListener("processorerror", (event) => {
  console.error("There was an error!");
});

Alternatively, you can use the onprocessorerror event handler property to establish a handler for the processorerror event (but note that this replaces other event listeners added using onprocessorerror, if any):

js
whiteNoiseNode.onprocessorerror = (event) => {
  console.error("There was an error!");
};

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • Using the Web Audio API