title: Chrome Extension - How to access webcam and Audio at intervals?
body: <p>I have a chrome extension I am using that I want to integrate with my webcam to do some funky computer vision and audio ML stuff.</p>
  <p>usuauly i'd do something liek this,</p>
  <p>for audio,</p>
  <pre><code>&lt;audio id=&quot;player&quot; controls&gt;&lt;/audio&gt;
  &lt;script&gt;
    const player = document.getElementById('player');
  
    const handleSuccess = function(stream) {
      if (window.URL) {
        player.srcObject = stream;
      } else {
        player.src = stream;
      }
    };
  
    navigator.mediaDevices.getUserMedia({ audio: true, video: false })
        .then(handleSuccess);
  &lt;/script&gt;
  </code></pre>
  <p>for webcam</p>
  <pre><code>&lt;video autoplay&gt;&lt;/video&gt;
  
  &lt;script&gt;
  const constraints = {
    video: true
  };
  
  const video = document.querySelector('video');
  
  navigator.mediaDevices.getUserMedia(constraints).
    then((stream) =&gt; {video.srcObject = stream});
  &lt;/script&gt;
  </code></pre>
  <p>With a chrome extension, would the best pathway be to use the background.js file - I am struggling to find any documentation or information about how I could do it with that.</p>
  <p>Thanks in advance!</p>