Skip to content

Commit

Permalink
Merge pull request #191 from screego/unsupported-errors
Browse files Browse the repository at this point in the history
fix: add unsupported browser error
  • Loading branch information
jmattheis committed Aug 16, 2024
2 parents a09b4e9 + a24ca71 commit d9b4d3c
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions ui/src/useRoom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,17 +317,31 @@ export const useRoom = (config: UIConfig): UseRoom => {
const share = async () => {
if (!navigator.mediaDevices) {
enqueueSnackbar(
'Could not start presentation. (mediaDevices undefined) Are you using https?',
{
variant: 'error',
persist: true,
}
'Could not start presentation. Are you using https? (mediaDevices undefined)',
{variant: 'error', persist: true}
);
return;
}
stream.current = await navigator.mediaDevices.getDisplayMedia({
video: {frameRate: loadSettings().framerate},
});
if (typeof navigator.mediaDevices.getDisplayMedia !== 'function') {
enqueueSnackbar(
`Could not start presentation. Your browser likely doesn't support screensharing. (mediaDevices.getDeviceMedia ${typeof navigator.mediaDevices.getDisplayMedia})`,
{variant: 'error', persist: true}
);
return;
}
try {
stream.current = await navigator.mediaDevices.getDisplayMedia({
video: {frameRate: loadSettings().framerate},
});
} catch (e) {
console.log('Could not getDisplayMedia', e);
enqueueSnackbar(`Could not start presentation. (getDisplayMedia error). ${e}`, {
variant: 'error',
persist: true,
});
return;
}

stream.current?.getVideoTracks()[0].addEventListener('ended', () => stopShare());
setState((current) => (current ? {...current, hostStream: stream.current} : current));

Expand Down

0 comments on commit d9b4d3c

Please sign in to comment.