is there an equivalent way to get the list of video devices connected to the PC? I have an external webcam connection in addition to the build-in one.
mediastreamtrack.getsources is working in chrome but firefox reported "TypeError: MediaStreamTrack.getSources is not a function". I am running firefox version 25.0.1
Thanks!
Please use below-mentioned code. It is working properly giving all audio and video devices list.
navigator.mediaDevices.enumerateDevices()
.then(function (devices) {
devices.forEach(function (device) {
var option = document.createElement('option');
option.value = device.deviceId;
if (device.kind === 'videoinput') {
option.text = device.label || 'camera' + (videoSelect.length + 1);
videoSelect.appendChild(option);
} else if (device.kind == 'audioinput') {
option.text = device.label || 'mic' + (audioSelect.length + 1);
audioSelect.appendChild(option);
}
});
})
.catch(function (err) {
console.log(err.name + ": " + err.message);
});
MediaDevices.enumerateDevices()
is now supported by Firefox and Chrome.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With