Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
193 views
in Technique[技术] by (71.8m points)

javascript - microphone permissionStatus state change to" granted" if it is "denied" or "prompt"

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 });

question from:https://stackoverflow.com/questions/65648392/microphone-permissionstatus-state-change-to-granted-if-it-is-denied-or-prom

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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> 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...