Compare commits

..

No commits in common. "cff1ddf0057e8253218b5c717749b85d3cd77e2f" and "afdc95d5c603b8c63ee8cfa6eaad542c03aa2f49" have entirely different histories.

View file

@ -103,25 +103,15 @@ export const useScanner = ({
};
const getCameraId = useCallback(async () => {
const stream = await navigator.mediaDevices.getUserMedia({
video: { facingMode: "environment" },
await navigator.mediaDevices.getUserMedia({
video: true,
});
if (
stream &&
stream.getVideoTracks().length &&
stream.getVideoTracks()[0].getSettings().deviceId
) {
return stream.getVideoTracks()[0].getSettings().deviceId;
}
const devices = await navigator.mediaDevices
.enumerateDevices()
.then((ds) => ds.filter((d) => d.kind === "videoinput"));
const back = devices.filter((d) =>
d.label.toLowerCase().includes("back")
)[0];
const back = devices.filter((d) => d.label === "Back Camera")[0];
return !back ? devices[0].deviceId : back.deviceId;
}, []);