prakash madariya
prakash madariya

Reputation: 31

How to set the microphone ask(default) for all the time in getUserMedia()?

I'm working on a project which is kind of speech-to-text. It has only a microphone option. Whatever you speak, it reads the input and shows you the converted text in the text area. What I want is whenever I click on the stop button, it should turn off the permission allow to ask(default). Because it will only ask for the first time in https. So, how can we make it ask for permission all the time? In HTTP it will ask all the time. Likewise, I want the same for https as well.

Please help. I'm tired searching that piece of code which could do the job. Thanks in advance.

Edited

 navigator.permissions.query({name:'microphone'}).then(function(result){
              if(result.state=="granted"){
                result.state="prompt"
              }
            });

Can I manipulate the permission states of browser like changing from granted to prompt?

Upvotes: 1

Views: 996

Answers (2)

Aison
Aison

Reputation: 165

Normally, this is not your job. This is controlled by client setting. When user starting the app(web app also), system will check the permission for camera/microphone/contact etc. User will decide if ask him to grant every time. For yours, if running in browser, system will check the browser permission, NOT YOUR WEB APP. If other web require the microphone permission first, when starting your app, normally no need to ask again. Also, your app revoke the microphone will disable other web app also. It is not correct!

Upvotes: 0

O. Jones
O. Jones

Reputation: 108641

navigator.permissions.revoke('microphone') might work. But, unfortunately the revoke() method is deprecated.

So, you would be wise not to rely on this requirement in your app.

On iOS Safari, it does ask every time.

Upvotes: 1

Related Questions