I'm implementing a video chat app with the OpenTokjs library with react using Next.js, when I tried to add the screen sharing feature before start sharing the screen the browser asks for permission and when the user click on the cancel button and refuse to give permission
it throws OT_USER_MEDIA_ACCESS_DENIED and even though I'm handling this error in the opentok callback error it still broke my Next.js App with Unhandled Runtime Error:
According to my research, this error is thrown by the browser because I tried it in Firefox and didn't face this issue here is similar issue reported here.
Here is the code:
publisherHelperRef.current = OT.initPublisher(
publisherProperties,
(error) => {
if (error?.name === "OT_USER_MEDIA_ACCESS_DENIED") {
setIsScreenShared(false)
return publishStream(getStreamSize())
}
else if (error) {
message.error(error?.name)
}
}
)
sessionHelperRef.current?.publish(
publisherHelperRef.current,
(error) => {
if (error) {
message.error(error?.name)
}
}
)