Firefox Tomorrow

web api event

BaseAudioContext: statechange event

View on MDN ↗

A statechange event is fired at a BaseAudioContext object when its state member changes.

Syntax

Use the event name in methods like addEventListener(), or set an event handler property.

addEventListener("statechange", (event) => { })

onstatechange = (event) => { }

Event type

A generic Event.

Examples

The following snippet is taken from our AudioContext states demo (see it running live.) The onstatechange handler is used to log the current state to the console every time it changes.

audioCtx.onstatechange = () => {
  console.log(audioCtx.state);
};

Specifications

SpecificationsStandards references are available on the canonical MDN page.

Browser compatibility

Browser compatibilityCompatibility data is available on the canonical MDN page.

See also