BaseAudioContext.state

The state read-only property of the BaseAudioContext interface returns the current state of the AudioContext.

Syntax

baseAudioContext.state;

Value

A DOMString. Possible values are:

  • suspended: The audio context has been suspended (with the AudioContext.suspend() method.)
  • running: The audio context is running normally.
  • closed: The audio context has been closed (with the AudioContext.close() method.)

Example

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

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

Specifications

Specification Status Comment
Web Audio API
The definition of 'state' in that specification.
Working Draft

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
stateChrome Full support 43Edge Full support ≤79Firefox Full support 53
Notes
Full support 53
Notes
Notes Originally implemented on AudioContext in Firefox 40.
IE No support NoOpera Full support YesSafari Full support 9
Prefixed
Full support 9
Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 53
Notes
Full support 53
Notes
Notes Originally implemented on AudioContext in Firefox Android 40.
Opera Android Full support YesSafari iOS Full support 9
Prefixed
Full support 9
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android Full support Yes

Legend

Full support
Full support
No support
No support
See implementation notes.
See implementation notes.
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

See also