onstatechange 特性为 BaseAudioContext interface defines an event handler function to be called when the statechange event fires: this occurs when the audio context's state changes.

句法

baseAudioContext.onstatechange = function() { ... };
					

范例

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

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

规范

规范 状态 注释
Web 音频 API
The definition of 'onstatechange' in that specification.
工作草案

浏览器兼容性

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. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
onstatechange Chrome 43 Edge ≤79 Firefox 53
53 注意事项
注意事项 Originally implemented on AudioContext in Firefox 40.
IE 不支持 No Opera Yes Safari 9 Prefixed
9 Prefixed
Prefixed Implemented with the vendor prefix: webkit
WebView Android Yes Chrome Android Yes Firefox Android 53
53 注意事项
注意事项 Originally implemented on AudioContext in Firefox Android 40.
Opera Android Yes Safari iOS 9 Prefixed
9 Prefixed
Prefixed Implemented with the vendor prefix: webkit
Samsung Internet Android Yes

图例

完整支持

完整支持

不支持

不支持

见实现注意事项。

见实现注意事项。

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

另请参阅

元数据

  • 最后修改: