A devicechange event is sent to a MediaDevices instance whenever a media device such as a camera, microphone, or speaker is connected to or removed from the system. It's a generic 事件 with no added properties.

冒泡 No
可取消 No
接口 事件
Event handler ondevicechange

范例

可以使用 devicechange event in an addEventListener 方法:

navigator.mediaDevices.addEventListener('devicechange', function(event) {
  updateDeviceList();
});
					

或使用 ondevicechange 事件处理程序特性:

navigator.mediaDevices.ondevicechange = function(event) {
  updateDeviceList();
}
					

规范

规范 状态
媒体捕获和流
The definition of 'devicechange' 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
devicechange event Chrome 57 Edge 12 Firefox 52 IE No Opera 34 Safari No WebView Android No Chrome Android No Firefox Android ? Opera Android 43 Safari iOS No Samsung Internet Android No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: