'getUserMedia notallowederror : permission denied

Um... when i play 'getUserMedia' on my phone, i got an error

from alert(e)) notallowederror : permission denied

What should i do?

it is a part of the index.js code(where the video & chating happens)...

async function getMedia(deviceId) {
  const initialConstraints = {
    audio: true,
    video: { facingMode: 'user' },
  };

  const cameraConstraints = {
    audio: true,
    video: { deviceId: { exact: deviceId } },
  };

  try {
    myStream = await navigator.mediaDevices.getUserMedia(
      deviceId ? cameraConstraints : initialConstraints
    );
    myFace.srcObject = myStream;

    if (!deviceId) {
      await getCameras();
    }
  } catch (e) {
    console.log(e);
    alert(e);
  }
}

I'm using rails app(web), and react-native(webview app), node.js(for realtime chating and video call like zoom by socket.io webRTC)

I ran it on the webview-app(hybrid), and that doesn't working... (working weeeell in browser but..) so i googling .. add the options..

video autoplay="" webkit-playsinline="webkit-playsinline" playsinline="playsinline" muted="true" id="myFace" width="350" height="400"

and video tag's parent is iframe, and it has attributes allow="camera;microphone;autoplay" and so on...

Also added the expo webview options like,,,

return useWebkit
allowInlineMediaPlayback={true}
mediaPlaybackRequiresUserAction={false}
javaScriptEnabled={true}
javaScriptEnabledAndroid
geolocationEnabled={true}

im so beginner.. can you help me out?? THanks!!!



Solution 1:[1]

If you get this error in Localhost or any site, you have to go to settings and search for microphone or webcam and enable/disable it manually,

enter image description here

enter image description here

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tadele Ayelegn