`
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);
});
Unable to receive audio devices and microphone in LWC. Maybe someone faced this problem?`
With Lightning Locker Service a lot of the browsers native javascript objects (like
window
,document
, etc.) are completely rewritten. This includes thenavigator.mediaDevices
object. Luckily Salesforce is making the switch to Lightning Web Security which opens some of these objects back up. It looks like you do have access to the navigator.mediaDevices object when Lightning Web Security is enabled. You can take a look at this article to see how to enable Lightning Web Security and use that object.