opentok-react
opentok-react copied to clipboard
App crashes in Chrome when user blocks access to media devices: Unhandled Rejection (OT_USER_MEDIA_ACCESS_DENIED)
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)
+1
Same problem. will anyone answer? thanks!
am facing a same problem
same problem
Facing same issue
@enricop89 Have you seen this error before?
@moficodes not really. Were you able to reproduce it?
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>
)}
</>
)