Try it, this doesn't work in this snippet but works in a file.
examples
<!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>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…