how to change the permissionStatus state to "granted" if it is "denied" or "prompt" in javascript? can anyone answer this question please? thanks in advance
navigator.permissions.query({name: 'microphone'}).then(permissionStatus => { // code });
how to change the permissionStatus state to "granted" if it is "denied" or "prompt" in javascript? can anyone answer this question please? thanks in advance
navigator.permissions.query({name: 'microphone'}).then(permissionStatus => { // code });
Try it, this doesn't work in this snippet but works in a file.
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<script type="text/javascript">
let havePermissions = false
const permissions = navigator
.mediaDevices
.getUserMedia({audio: true, video: false})
permissions.then((stream) => {
alert('accepted the permissions');
havePermissions: !havePermissions
})
.catch((err) => {
havePermissions: false
console.log(`${err.name} : ${err.message}`)
});
</script>
</body>
</html>