How to access the webcam by javascript

Leonardo Lacerda picture Leonardo Lacerda · Mar 14, 2013 · Viewed 85.2k times · Source

I need to open the webcam via JavaScript I know it is possible to access the html5 by <video> but need access webcam with pure JavaScript

Can someone help me or give me some ideas?

I need only access the webcam with JavaScript and sorry for my English, I'm using Google translator.

I can't use tag '< video >'

Answer

jAndy picture jAndy · Mar 14, 2013

As I stated as comment, I'm confused about your wording. You said, you know that "HTML5" can access the webcam, but you need it by pure Javascript.

Well, in case you don't know, HTML5 introduced the such called WebRTC which is short for Real-Time Communications. Part of that, a new thing called navigator.getUserMedia() navigator.mediaDevices.getUserMedia(constraints) was introduced as well. That is, an ECMAscript object, which allows you to get access to the users machine WebCam and Microphone devices.

As you can see, the whole show is embedded in the HTML5 rollout / spec, so we cannot really separate the Javascript from the HTML5 here.

Further reading: