0

How to re-ask permission to microphone in browsers?

My code is here:

function askPermission() {
  var constraints = { audio: true, video: false };

  navigator.mediaDevices
    .getUserMedia(constraints)
    .then(function(stream) {
      let audioContext = new AudioContext();
      console.log(audioContext);
    })
    .catch(function(err) {
      window.location.reload();
    });
}
Ivan V.
  • 7,593
  • 2
  • 36
  • 53
Almas
  • 319
  • 2
  • 15

1 Answers1

1

You can't.

User needs to go to browser settings and allow it manually.

More info: ask for geolocation permission again if it was denied

Ivan V.
  • 7,593
  • 2
  • 36
  • 53