Nettalk - Switching between front and back Cameras during runtime?

@Bruce - Is it possible to switch between the front and back cameras with the Webcam control on NetTalk? A client of ours want to have this kind of capability with the WebCam form control included on our web app.

I’ve tried to look for some clues on how the WebCam form control is generated within the code and I’ve found an option called “facingMode”. As far as I remember there are two accepted values for this: ‘user’ or ‘environment’ for front and back cameras respectively.

image

Upon, further digging, I’ve found that the webcam control in NetTalk is generated using the javascript file named “jquery.nt-cam.js”.

If I remember correctly, it’s possible to change a jquery widgets properties on runtime via javascript code and I would like to be able to switch between front and back cameras using this.

What javascript code do I need to switch between the front and back-facing cameras?

Thanks in advance.

Hi Warp,

I think it’s do’able, with a small javascript function. You will need to experiment a bit though, and hopefully feed back your results.

From a javascript perspective you are going to stop the stream, reset the options, then start it again.
So something like;
$("#loc_controlme_webcam").ntcam(“stop”);
$("#loc_controlme_webcam").ntcam(“video”,"{facingMode:‘user’}");
$("#loc_controlme_webcam").ntcam(“start”);

Test that in a little javascript function to see if it works. Once you have it working in a JavaScript function I can help you translate it into Clarion.

Sorry for being vague, but alas right now I’m remote to my development machine, and that doesn’t currently have any camera attached, so it’s not easy for me to test from here…

1 Like

Thanks for the quick response, Bruce!
What I’m only looking for are the javascript codes needed to modify some of the properties of the webcam control during runtime (on the browser) and those jquery codes you’ve indicated are exactly the hint I needed.

I’ll give the jquery codes a shot and see where I can go from there.

Again, thanks for the help!

my guess is you’ll need to Stop and Start in order for he change to take effect. From what I can see on the internet the option is only applied when the stream starts. So changing the option means stopping and starting the stream.

1 Like