How to trigger microphone permission popup on chrome (javascript)
18,854
You need to get the permission using the navigator object.
navigator.mediaDevices.getUserMedia({ audio: true })
.then(function(stream) {
console.log('You let me use your mic!')
})
.catch(function(err) {
console.log('No mic for you!')
});
Also you need to run it on HTTPS and on a website instead of using IP addresses
Related videos on Youtube
Comments
-
Hakan almost 2 years
-
saudblaze about 4 yearsIt shows in console but how can we show modal to user .
-
Saransh Kataria about 4 yearsyou need to replace the console.log logic with whatever you use to show modals
-
aspiring1 almost 4 years@SaranshKataria : I have some javascript code in my flask webserver, when I run it on localhost, I can record easily. But when the code is on the server, when I press the button for Record, I don't see any recording start, do I need to run it on
HTTPS
instead ofHTTP
and on a website? Isn'tHTTPS
more about being secure? -
Saransh Kataria almost 4 years@aspiring1 since media and camera are powerful features, the web standards enforce them to work only on HTTPS websites. You can read more about it on developer.mozilla.org/en-US/docs/Web/API/MediaDevices/…
-
CodeZila about 3 yearsThe popup in my chrome browser has Allow and Block buttons interchanged. Any browser setting for that?