MediaDevices: devicechange event

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

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
devicechange_event
57
12
52
No
34
11
No
No
?
43
11
No

See also

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/devicechange_event