opentok-react icon indicating copy to clipboard operation
opentok-react copied to clipboard

App crashes in Chrome when user blocks access to media devices: Unhandled Rejection (OT_USER_MEDIA_ACCESS_DENIED)

Open hiramhibbard opened this issue 6 years ago • 8 comments

If a user denies access to the camera in Chrome, the app crashes with the following error: Unhandled Rejection (OT_USER_MEDIA_ACCESS_DENIED): End-user denied permission to hardware devices (getUserMedia error: NotAllowedError)

hiramhibbard avatar Jan 19 '19 00:01 hiramhibbard

+1

fadiquader avatar Apr 25 '19 10:04 fadiquader

Same problem. will anyone answer? thanks!

demyandubovik avatar Aug 26 '20 09:08 demyandubovik

am facing a same problem

rohanrana avatar Mar 21 '21 11:03 rohanrana

same problem

ikrainiev avatar Mar 30 '21 14:03 ikrainiev

Facing same issue image

colin-shah avatar Apr 30 '21 05:04 colin-shah

@enricop89 Have you seen this error before?

moficodes avatar Nov 08 '21 17:11 moficodes

@moficodes not really. Were you able to reproduce it?

enricop89 avatar Nov 08 '21 17:11 enricop89

i've solved the issue with this implementation

 const [hasUserMedia, setHasUserMedia] = useState<boolean>(false)
  const [errorMsg, setErrorMsg] = useState<string>()
  useEffect(() => {
    const videoConstraints = {
      height: window.innerHeight / 2,
      width: window.innerWidth / 2,
    }
    navigator.mediaDevices
      .getUserMedia({ video: videoConstraints, audio: true })
      .then((stream: MediaStream) => {
        if (stream) setHasUserMedia(true)
      })
      .catch((err: DOMException) => {
        setErrorMsg(err.message)
      })
  }, [])

and then you can check in return

  return (
    <>
      <h1 style={{ color: 'red' }}>{errorMsg}</h1>
      {hasUserMedia && apiKey && sessionId && token && room && (
        <OTSession
          apiKey={apiKey}
          sessionId={sessionId}
          token={token}
        >
           <OTPublisher />
        </OTSession>
      )}
    </>
  )

asemqaffaf avatar Nov 09 '21 14:11 asemqaffaf