Jump to content

Add this to JavaScript tutorial


DianeTereshko
 Share

Recommended Posts

Add this to navigator object, it is really cool,

 

<video id="media" width="300" height="300" controls></video>

navigator.getWebcam = (navigator.getUserMedia || navigator.webKitGetUserMedia || navigator.moxGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia);
if (navigator.mediaDevices.getUserMedia) {
    navigator.mediaDevices.getUserMedia({
            audio: true,
            video: true
        })
        .then(function (stream) {
            var video = document.getElementById("media");
            video.srcObject = stream;
            video.play();
 
        })
        .catch(function (e) {
            logError(e.name + ": " + e.message);
        });
} else {
    navigator.getWebcam({
            audio: true,
            video: true
        },
        function (stream) {
            //Display the video stream in the video object
        },
        function () {
            logError("Web cam is not accessible.");
        });
}

This show your web cam in web-page

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...