• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Allow camera access - show camera view -- don’t start recording video

chrisj

Coder
Thansks again for all the previous help.

This code below works successfully to capture/record (after camera access granted) when the start button is selected. I'm trying to add the ability where (after camera access is allowed) the camera view appears, without recording starting automatically. (And have the camera view displayed while recording).

Currently, the screen is black upon page load, and remains black after camera access and while capture/recording. Nothing appears in the screen until the recording automatically plays until: 'Stop".

Upon researching, I believe I may need to "capture the stream from the video element and put it through the MediaRecorder object", but I don't know how to do that. Any help is appreciated. Here's the current code:

JavaScript:
var video = document.querySelector("video");
let params = { audio: true, video: { facingMode: { exact: "environment" } } };

let blobs = [];
let stream, mediaRecorder, blob;

async function startRecording() {
stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: true,
});

mediaRecorder = new MediaRecorder(stream);
mediaRecorder.ondataavailable = (event) => {
// Let's append blobs for now, we could also upload them to the network.
if (event.data) {
blobs.push(event.data);
 

Top