The MediaDeviceInfo
interface contains information that describes a single media input or output device. The list of devices obtained by calling navigator.mediaDevices.enumerateDevices()
is an array of MediaDeviceInfo
objects, one per media device.
Properties
MediaDeviceInfo.deviceId
Read only- Returns a
DOMString
that is an identifier for the represented device that is persisted across sessions. It is un-guessable by other applications and unique to the origin of the calling application. It is reset when the user clears cookies (for Private Browsing, a different identifier is used that is not persisted across sessions). MediaDeviceInfo.groupId
Read only- Returns a
DOMString
that is a group identifier. Two devices have the same group identifier if they belong to the same physical device — for example a monitor with both a built-in camera and a microphone. MediaDeviceInfo.kind
Read only- Returns an enumerated value that is either
"videoinput"
,"audioinput"
or"audiooutput"
. MediaDeviceInfo.label
Read only- Returns a
DOMString
that is a label describing this device (for example "External USB Webcam").
For security reasons, the label
field is always blank unless an active media stream exists or the user has granted persistent permission for media device access. The set of device labels could otherwise be used as part of a fingerprinting mechanism to identify a user.
Methods
None.
Example
Here's an example that uses enumerateDevices()
to get a list of devices.
if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) { console.log("enumerateDevices() not supported."); return; } // List cameras and microphones. navigator.mediaDevices.enumerateDevices() .then(function(devices) { devices.forEach(function(device) { console.log(device.kind + ": " + device.label + " id = " + device.deviceId); }); }) .catch(function(err) { console.log(err.name + ": " + err.message); });
This might produce:
videoinput: id = csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8= audioinput: id = RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM= audioinput: id = r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=
or if one or more media streams are active, or if persistent permissions have been granted:
videoinput: FaceTime HD Camera (Built-in) id=csO9c0YpAf274OuCPUA53CNE0YHlIr2yXCi+SqfBZZ8= audioinput: default (Built-in Microphone) id=RKxXByjnabbADGQNNZqLVLdmXlS0YkETYCIbg+XxnvM= audioinput: Built-in Microphone id=r2/xw1xUPIyZunfV1lGrKOma5wTOvCkWfZ368XCndm0=
Specifications
Specification | Status | Comment |
Media Capture and StreamsThe definition of 'MediaDevicesInfo' in that specification. | Candidate Recommendation | Initial definition |
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
MediaDeviceInfo
|
Chrome Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Edge
Full support 12 |
Firefox
Full support 39 |
IE
No support No |
Opera No support No No support No Notes' This interface can be used in Opera by using the adapter.js polyfill. |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Chrome Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Firefox Android
Full support 39 |
Opera Android No support No No support No Notes' This interface can be used in Opera by using the adapter.js polyfill. |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
deviceId
|
Chrome Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Edge
Full support 12 |
Firefox
Full support 39 |
IE
No support No |
Opera No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Chrome Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Firefox Android
Full support 39 |
Opera Android No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
groupId
|
Chrome Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Edge
Full support 12 |
Firefox Full support 39 Full support 39 Notes' Prior to Firefox 67, related devices are not actually grouped together by |
IE
No support No |
Opera No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Chrome Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Firefox Android Full support 39 Full support 39 Notes' Prior to Firefox 67, related devices are not actually grouped together by |
Opera Android No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
kind
|
Chrome Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Edge
Full support 12 |
Firefox
Full support 39 |
IE
No support No |
Opera No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Chrome Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Firefox Android
Full support 39 |
Opera Android No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
label
|
Chrome Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Edge
Full support 12 |
Firefox
Full support 39 |
IE
No support No |
Opera No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari
No support No |
WebView Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Chrome Android Full support 55 Full support 55 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
Firefox Android
Full support 39 |
Opera Android No support No No support No Notes' This property can be used in Opera by using the adapter.js polyfill. |
Safari iOS
No support No |
Samsung Internet Android Full support 6.0 Full support 6.0 Notes' For earlier versions, this interface is available through the adapter.js polyfill |
toJSON()
|
Chrome
Full support Yes |
Edge
Full support 18 |
Firefox
Full support Yes |
IE
No support No |
Opera No support No No support No Notes' For earlier versions, this method is available through the adapter.js polyfill |
Safari
No support No |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support Yes |
Opera Android No support No No support No Notes' For earlier versions, this method is available through the adapter.js polyfill |
Safari iOS
No support No |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
MediaDeviceInfo by Mozilla Contributors is licensed under CC-BY-SA 2.5.