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

AudioContextstate属性是只读的,返回AudioContext的当前状态。

语法

var audioCtx = new AudioContext();
var myState = audioCtx.state;

返回值

DOMString,可能的值如下:

例子

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

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

规范

Specification Status Comment
Web Audio API
state
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,