Below is the code I am using from Twilio to access the local camera on the browser :
async function ShowLocalVideo() {
Twilio.Video.createLocalVideoTrack().then(track => {
const localMediaContainer = document.getElementById('LocalMedia');
localMediaContainer.appendChild(track.attach());
});
}
I want to ensure that the user has granted access to the camera before proceeding with other steps. Ideally, I would like to wait for their response. This is why I am calling:
await ShowLocalVideo();
alert('Hi !');
However, the alert Hi ! pops up before the browser prompt asking for camera access.
Is there a way to pause the execution of the code until the user responds to This file wants to use your camera. ?