How can i trigger this modal on javascript button click
How to trigger microphone permission popup on chrome (javascript) [duplicate]
Asked Answered
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
It shows in console but how can we show modal to user . –
Candless
you need to replace the console.log logic with whatever you use to show modals –
Drypoint
@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 of HTTP
and on a website? Isn't HTTPS
more about being secure? –
Scharaga @Scharaga 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/… –
Drypoint
The popup in my chrome browser has Allow and Block buttons interchanged. Any browser setting for that? –
Bim
© 2022 - 2024 — McMap. All rights reserved.
navigator.mediaDevices.getUserMedia
now (used to be justnavigator.getUserMedia
) – Seat