How can I make it so that the camera Faces the Environment

I'm making a Visual Campus Map for my Assignment so i'm trying to get the camera to face the environment/back camera instead of myself / front camera

I've tried making a custom reporter block called "Use Back camera" with a Javascript function attached it to it.

Here is the JavaScript Function I used:

let stream = null;
let isExtensionEnabled = false;

function accessBackCamera(videoElement) {
if (!isExtensionEnabled) {
navigator.mediaDevices.getUserMedia({
video: { facingMode: "environment" }
}).then(function(newStream) {
stream = newStream;
videoElement.srcObject = stream;
videoElement.play();
isExtensionEnabled = true;
}).catch(function(error) {
console.error("Failed to access back camera:", error);
});
} else {
if (stream) {
stream.stop();
videoElement.srcObject = null;
}
isExtensionEnabled = false;
}
}

function toggleExtensionState(videoElement) {
accessBackCamera(videoElement);
}

Are there any solutions to fix this issue? Thanks

Not a solution, but I have run into issues like this before. There should very much be a feature to switch between cameras on devices with multiple cameras.

In my browser (Chrome on Mac, but I bet something like this works in any browser) you can set which camera to use. For me it's done in this non-obvious way that took me a long time to find (listening in, Google?):

Open browser preferences (⌘,)(non-Mac: ↑,)
Choose Privacy and security in the left menu
Choose Site settings
Choose Camera
Right at the top will be a pulldown menu of cameras.

Then do the SET VIDEO CAPTURE TO True in the Snap! window.

(EDIT: This is on my computer; I haven't tried it on my phone.)

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.