Well it is recording because you are piping the video stream through the MediaRecorder object. Check out the following page for example code…
Go to the section titled “Get the media stream” for an example of where they request the stream and then use that stream to bind to the video element (in the code section above). This is the line video.srcObject = stream;
Now if you look at your code, you will notice that you also get the stream, but then you send that stream into the MediaRecorder object’s constructor. This is what it is setting it up for recording. I hope you get what I am saying here.
Thanks again for your reply/help.
Currently, when I open my page, the camera screen is black, and then I select ‘Start’, it asks for Mic/Cam access and the webcam records, but screen stays black. When I select ‘Stop’, the screen displays the recording and the Player time clock proceeds while playing back.
When I add in your JS the screen displays the Cam view, upon giving Access, the Player timer/clock starts, but nothing is being recorded and selecting ‘Stop’ seems to have no affect.
I’d like to keep all my current abilities, but just have the cam display/view after access, keep the cam display/view while recording.
Any help with modifying the code is appreciated.
No no, don’t add in my example code. My example runs by itself. On codepen it should ask for camera access, once granted it should immediately start showing the camera view on the page. My example is meant to check that you have a working camera and demonstrate how to pipe a video camera stream through the web page.
So the first question is, do you see your camera view on the page when you start my code pen? If you still see black only, then you have a problem with your camera or the browser.
Great… so that is an example of how you would pipe a stream through to the video element. So this addresses your question number 1. You have a working example of how you can have the camera view appearing without recording starting automatically.
Now, if you compare this to your code, you will see that you are taking stream and putting it through an object called MediaRecorder. Where in my example I don’t do this. Since you are running it through MediaRecorder, what is triggering your recording when you click the start button.
So logically this means that you need to take the stream, pipe it to the video element and then after it goes to the video element, pipe that stream through the recorder using the start button.
Maybe when you click start, rather than making the getUserMedia call, you have the function take in a stream. You can fetch the stream by capturing it from the video element. To see how this is done for recording, check out this link…
To recap, you pipe your camera through to the video element like demonstrated. Next, when someone clicks the button to start recording, you capture the stream from the video element and pipe it through the MediaRecorder object like shown in your code. When they click stop, then you stop the media recorder.
Thanks you for the reply.
After trial and error, I can’t see to add the functionality where the camera view appears, without recording starting automatically and have the camera view displayed while recording, as I am not very knowledgable in js
Any additional help is welcomed