devicechange
每当媒体设备(例如相机,麦克风或扬声器)连接到系统或从系统中移除时,devicechange
事件就会被发送到 MediaDevices
实例。 这是一个没有附加属性的通用 Event
。
一般信息
- 规范
- Media Capture and Streams
- 接口
- Event
- 是否冒泡
- No
- 是否可取消
- No
- 对象
MediaDevices
- 默认动作
- None
属性
Property | Type | Description |
---|---|---|
target 只读 |
EventTarget |
事件对象 (位于DOM树最上面的元素). |
type 只读 |
DOMString |
事件类型. |
bubbles 只读 |
Boolean (en-US) |
是否冒泡 |
cancelable 只读 |
Boolean (en-US) |
是否可被取消 |
相关事件
无.
样例
有关使用 devicechange
事件更新屏幕上设备列表的示例,请参阅 Example in MediaDevices.ondevicechange。
Specifications
Specification | Status | Comment |
---|---|---|
Media Capture and Streams devicechange |
Candidate Recommendation | Initial specification. |
浏览器兼容性
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! (en-US)
Feature | Chrome | Firefox (Gecko) | Edge | Internet Explorer | Opera | Safari (WebKit) | |
---|---|---|---|---|---|---|---|
Basic support | 52.0 | 51 (51)[1] | (Yes) | ? | ? | 39 | ? |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | Firefox OS | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|---|
Basic support | 未实现 | 未实现 | (Yes) | ? | ? | ? | 39 | ? | 未实现 |
[1] Support for the devicechange
event and for MediaDevices.ondevicechange
landed in Firefox 51, but only for Mac, and disabled by default. It can be enabled by setting the preference media.ondevicechange.enabled
to true
. Support for this event was added for Linux and Windows—and it was enabled by default—starting in Firefox 52.