Stack Exchange Network
Stack Exchange network consists of 181 Q&A communities including
Stack Overflow
, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack Exchange
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this community
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
We are trying to use lightning web component for a requirement in Salesforce where we try to capture the image of the user via webcam and this requirement is specifically for laptops and desktops. Below is how we were trying to access the webcam function
navigator.getMedia = ( navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
navigator.getMedia(
video: true,
audio: false
(stream) => {
/* Capture the stream */
(err) => {
console.log("An error occured! " + err);
It seems the LWC compiler is not allowing navigator object to have getMedia function whereas with normal html and vanilla javascript we were able to do it.
Did anyone of you ever faced this scenario back and do we have a workaround as of now to fix this issue?
this is not a direct Web Component Issue. Most WebRTC Apis are not supported in Lockerservice which is enforced on all LWCs. The only "workaround" is to do it via an Aura Component nailed down to Api V.39, do it externally and embed it via lightning:container or do it via Visualforce (and iframing the page somewhere else if required).
Regards