Handle camera errors

This commit is contained in:
Marvin Sextro 2021-07-25 01:53:02 +02:00
parent dbd076ae21
commit 36e080cb35
1 changed files with 3 additions and 8 deletions

View File

@ -81,14 +81,6 @@ function Form(): JSX.Element {
return;
}
// Check permissions to camera device
try {
navigator.mediaDevices.getUserMedia({video: true});
} catch (e) {
setErrorMessage("noCameraAccess");
return;
}
// Get preview Element to show camera stream
const previewElem: HTMLVideoElement = document.querySelector('#cameraPreview');
@ -108,6 +100,9 @@ function Form(): JSX.Element {
setGlobalControls(undefined);
setIsCameraOpen(false);
}
if (error !== undefined) {
setErrorMessage("noCameraAccess");
}
}
)
);