We're looking for a user researcher to understand the needs of developers and designers. Is this you or someone you know? Check out the post: https://mzl.la/2IGzdXS

AudioContext.onstatechange

AudioContextonstatechange属性定义了一个事件处理器函数,触发statechange会被调用,也就是说audio context的状态发生变化时会执行。

语法

var audioCtx = new AudioContext();
audioCtx.onstatechange = function() { ... };

例子

下面这段代码是AudioContext states DEMO (直接运行)中的,其中onstatechange处理器会在每次当前state发生变化时把它输出到控制台。

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

规范

Specification Status Comment
Web Audio API
onstatechange
Working Draft  

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 43.0 40.0 (40.0)  未实现 ? ?
Feature Android Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support ? ? ? ? ? ? ?

另见

文档标签和贡献者

此页面的贡献者: ayqy
最后编辑者: ayqy,