- Start and Stop Web Cam using getUserMedia HTML5 feature.
- <html>
- <head>
- <meta charset="utf-8">
- <title>JS Bin</title>
- <script>
- navigator.getUserMedia = ( navigator.getUserMedia ||
- navigator.webkitGetUserMedia ||
- navigator.mozGetUserMedia ||
- navigator.msGetUserMedia);
- var webcamStream;
- function startWebCam() {
- if (navigator.getUserMedia) {
- navigator.getUserMedia (
- // constraints
- {
- video: true,
- audio: false
- },
- // successCallback
- function(localMediaStream) {
- var video = document.querySelector('video');
- video.src = window.URL.createObjectURL(localMediaStream);
- webcamStream = localmediaStream;
- },
- // errorCallback
- function(err) {
- console.log("The following error occurred: " + err);
- }
- );
- } else {
- console.log("getUserMedia not supported");
- }
- }
- function stopWebcam() {
- webcamStream.stop();
- }
- </script>
- </head>
- <body >
- <video width=200 height=200 id="video" controls autoplay></video>
- <button onclick="startWebcam();">Start Webcam</button>
- <button onclick="stopWebcam();">Stop Webcam</button>
- </body>
- </html>
Thursday, June 25, 2015
getUserMedia Advance Features of HTML5 WebCam Kit
Web Cam Enable Application example
- <html>
- <head>
- <meta charset="utf-8">
- <title>JS Bin</title>
- <script>
- navigator.getUserMedia = ( navigator.getUserMedia ||
- navigator.webkitGetUserMedia ||
- navigator.mozGetUserMedia ||
- navigator.msGetUserMedia);
- if (navigator.getUserMedia) {
- navigator.getUserMedia (
- // constraints
- {
- video: true,
- audio: false
- },
- // successCallback
- function(localMediaStream) {
- var video = document.querySelector('video');
- video.src = window.URL.createObjectURL(localMediaStream);
- },
- // errorCallback
- function(err) {
- console.log("The following error occured: " + err);
- }
- );
- } else {
- console.log("getUserMedia not supported");
- }
- </script>
- </head>
- <body >
- <video width=200 height=200 id="video" controls autoplay></video>
- </body>
- </html>
Subscribe to:
Posts (Atom)