skip to Main Content
  const checkMicrophoneAccess = async () => {
    try {
      const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
      stream.getTracks().forEach((track) => track.stop());
      localStorage.setItem("isMicAllowed", true);
    } catch (error) {
     console.log(error)
    }
  };

while trying to turn on automatically, getting error of "NotAllowedError: Permission denied"

How can I enable microphone access in a browser automatically from a React.js frontend application without showing the browser’s default pop-up? For example, the Google Meet web application uses its own custom pop-up to manage microphone access across all browsers like Chrome, Safari etc. I need a similar flow, ideally a silent enabling process.

2

Answers


  1. You cannot enable the browser’s microphone access automatically without showing the browser’s permission notification. This is by design and is an important security and privacy feature.

    The user controls that notification, not the front-end developer.

    On systems managed by an admin, the admin can set a policy to control that notification as well.

    Login or Signup to reply.
  2. ideally a silent enabling process.

    As many other permissions they must be requested on demand and approved by user each time you need them. This is security related policy. If it was not like this you can spy on user and violate user`s privacy. This is not allowed.

    On trusted https domains (like from Google) user can allow usage of some devices automatically after first request and allow their usage each time code request them. But still in this case it will not be silently. Browser will indicate in address bar that code uses camera/microphone etc and user will know this.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search