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 Event
with no added properties.
Bubbles | No |
Cancelable | No |
Interface | Event
|
Event handler | ondevicechange
|
Example
You can use the devicechange
event in an addEventListener
method:
navigator.mediaDevices.addEventListener('devicechange', function(event) {
updateDeviceList();
});
Or use the ondevicechange
event handler property:
navigator.mediaDevices.ondevicechange = function(event) {
updateDeviceList();
}
Specifications
Specification | Status |
---|---|
Media Capture and StreamsThe definition of 'devicechange' in that specification. | Candidate Recommendation |
Browser compatibility
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.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
devicechange event
|
Chrome
Full support 57 |
Edge
Full support 12 |
Firefox
Full support 52 |
IE
No support No |
Opera
Full support 34 |
Safari
No support No |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
? |
Opera Android
Full support 43 |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
MediaDevices: devicechange event by Mozilla Contributors is licensed under CC-BY-SA 2.5.