title: Event triggered when the video stream is started, with getUserMedia
body: <p>I'm using the ZXing JS barcode scanner library <a href="https://github.com/zxing-js/library/" rel="nofollow noreferrer">https://github.com/zxing-js/library/</a> with a video stream input (webcam or phone camera), as detailed in the following code.</p>
  
  <p><strong>In general, how to add an event listener to a <code>&lt;video&gt;</code> to do an action when a video stream has just started?</strong> (a video using the <a href="https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia" rel="nofollow noreferrer"><code>MediaDevices.getUserMedia</code></a> video stream API, started from ZXing's <code>decodeFromInputVideoDevice</code>)?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>const codeReader = new ZXing.BrowserQRCodeReader();
  
  codeReader
    .decodeFromInputVideoDevice(undefined, 'video')  // uses the default input
    .then(result =&gt; console.log(result.text))  // this happens when the barcode is found / recognized
    .catch(err =&gt; console.error(err));</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://unpkg.com/@zxing/library@0.15.2/umd/index.min.js"&gt;&lt;/script&gt;
  &lt;video id="video"&gt;&lt;/video&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Note: for now I'm using <code>setTimeout(..., 2000)</code> when the user has clicked on the button to start the video, but obviously this fails in the case there is a dialog box "Do you want to allow this website to use the camera device?", then 2 seconds is not enough. A listener on event "VideoHasJustStarted" would be better.</p>
  
  <p><strong>Edit:</strong><br>
  <a href="https://jsfiddle.net/j6m0wuk7/" rel="nofollow noreferrer">Here is a jsFiddle</a> showing the issue: not working with various events: <code>started</code>, <code>devicechange</code>.</p>