A statechange
event is fired at a BaseAudioContext
object when its state
member changes.
A statechange
event is fired at a BaseAudioContext
object when its state
member changes.
Use the event name in methods like addEventListener()
, or set an event handler property.
js
addEventListener("statechange", (event) => { }) onstatechange = (event) => { }
A generic Event
.
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.
js
audioCtx.onstatechange = () => { console.log(audioCtx.state); };
Specification |
---|
Web Audio API # dom-baseaudiocontext-onstatechange |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
statechange_event |
41 | 14 | 40 | No | 28 | 9 | 41 | 41 | 40 | 28 | 9 | 4.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/statechange_event