Thursday, June 25, 2015

getUserMedia Advance Features of HTML5 WebCam Kit

  1. Start and Stop Web Cam using getUserMedia HTML5 feature.

  2. <html>
  3. <head>
  4.  <meta charset="utf-8">
  5.  <title>JS Bin</title>
  6.  <script>
  7.     navigator.getUserMedia = ( navigator.getUserMedia ||
  8.                                navigator.webkitGetUserMedia ||
  9.                                navigator.mozGetUserMedia ||
  10.                                navigator.msGetUserMedia);
  11. var webcamStream;
  12.  
  13.  function startWebCam() {
  14.     if (navigator.getUserMedia) {
  15.         navigator.getUserMedia (
  16.             // constraints
  17.             {
  18.                 video: true,
  19.                 audio: false
  20.             },
  21.  
  22.             // successCallback
  23.             function(localMediaStream) {
  24.                 var video = document.querySelector('video');
  25.                 video.src = window.URL.createObjectURL(localMediaStream);
  26.                 webcamStream = localmediaStream;
  27.             },
  28.  
  29.             // errorCallback
  30.             function(err) {
  31.                 console.log("The following error occurred: " + err);
  32.             }
  33.         );
  34.     } else {
  35.         console.log("getUserMedia not supported");
  36.     }
  37. }
  38. function stopWebcam() {
  39.     webcamStream.stop();
  40. }
  41.  </script>
  42. </head>
  43. <body >
  44.      <video width=200 height=200 id="video" controls autoplay></video>
  45.      <button onclick="startWebcam();">Start Webcam</button>
  46.      <button onclick="stopWebcam();">Stop Webcam</button>
  47. </body>
  48. </html>

1 comment:

  1. How To Gamble Online With Casino Sites in Illinois
    When it 여주 출장마사지 comes to online gambling, there are many ways 토토 사이트 you can wager online. You can pick up 평택 출장안마 the cash or cash 광주광역 출장샵 games offered on 의정부 출장안마 any of the

    ReplyDelete