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 theAudioContext.suspend()
method.)running
: The audio context is running normally.closed
: The audio context has been closed (with theAudioContext.close()
method.)
Example
The following snippet is taken from our AudioContext states demo ([[../../../../../../../mdn.github.io/webaudio-examples/audiocontext-states/index|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 APIThe definition of 'state' in that specification. | Working Draft |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
state
|
Chrome
Full support 43 |
Edge
Full support ≤79 |
Firefox Full support 53 Full support 53 Notes' Originally implemented on |
IE
No support No |
Opera
Full support Yes |
Safari Full support 9 Full support 9 Prefixed' Implemented with the vendor prefix: webkit |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android Full support 53 Full support 53 Notes' Originally implemented on |
Opera Android
Full support Yes |
Safari iOS Full support 9 Full support 9 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
BaseAudioContext.state by Mozilla Contributors is licensed under CC-BY-SA 2.5.