Skip to content

Commit

Permalink
Add error handling for navigator.mediaDevices
Browse files Browse the repository at this point in the history
Resolves #225
  • Loading branch information
Sean-Der committed Jan 12, 2025
1 parent 3d2f2f9 commit 83c8f26
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions web/src/components/publish/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ function Player(props) {
const peerConnection = new RTCPeerConnection() // eslint-disable-line
let stream = null

if (!navigator.mediaDevices) {
setMediaAccessError({name: 'NoMediaDevices'})
return
}

const mediaPromise = useDisplayMedia ?
navigator.mediaDevices.getDisplayMedia(mediaOptions) :
navigator.mediaDevices.getUserMedia(mediaOptions)
Expand Down Expand Up @@ -107,6 +112,7 @@ function Player(props) {
}

const mediaErrorMessages = {
NoMediaDevices: `MediaDevices API was not found. Publishing in Broadcast Box requires HTTPS 👮`,
NotAllowedError: `You can't publish stream using your camera, because you have blocked access to it 😞`,
NotFoundError: `Seems like you don't have camera 😭 Or you just blocked access to it...\n` +
`Check camera settings, browser permissions and system permissions.`,
Expand Down

0 comments on commit 83c8f26

Please sign in to comment.