Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html lang="en">
<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) {
  console.log("toto");
   navigator.getUserMedia (
      // constraints
      {
         video: true,
         audio: false
      },
      // successCallback
      function(localMediaStream) {
         var video = document.querySelector('video');
         video.src = window.URL.createObjectURL(localMediaStream);
         webcamStream = localMediaStream.getTracks()[0];
      },
      // errorCallback
      function(err) {
         console.log("The following error occured: " + err);
      }
   );
} else {
   console.log("getUserMedia not supported");
}  
}
      
      function stopWebcam() {
      webcamStream.stop();
      }
  </script>
</head>
<body >
  <video width=400 height=400 id="video" controls autoplay></video>
  <p>
  <button onclick="startWebcam();">Start WebCam</button>
  <button onclick="stopWebcam();">Stop WebCam</button> 
  </p>
</body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
AuroreDechampspro
0viewers