IssyPutchy

webcam viewer

Apr 4th, 2021
629
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Display Webcam Stream</title>
  6.  
  7. <style>
  8. #container {
  9.     margin: 0px auto;
  10.     width: 250px;
  11.     height: 250px;
  12.     border: 10px #333 solid;
  13. }
  14. #videoElement {
  15.     width: 250px;
  16.     height: 250px;
  17.     background-color: #666;
  18. }
  19. </style>
  20. </head>
  21.  
  22. <body>
  23. <div id="container">
  24.     <video autoplay="true" id="videoElement">
  25.    
  26.     </video>
  27. </div>
  28. <script>
  29. var video = document.querySelector("#videoElement");
  30.  
  31. if (navigator.mediaDevices.getUserMedia) {
  32.   navigator.mediaDevices.getUserMedia({ video: true })
  33.     .then(function (stream) {
  34.       video.srcObject = stream;
  35.     })
  36.     .catch(function (err0r) {
  37.       console.log("Something went wrong!");
  38.     });
  39. }
  40. </script>
  41. </body>
  42. </html>
  43.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×