1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32

content / test / data / media / getusermedia-real-webcam.html [blame]

<html>
<head>
  <script type="text/javascript" src="webrtc_test_utilities.js"></script>
  <script type="text/javascript">
  $ = function(id) {
    return document.getElementById(id);
  };

  async function getUserMediaAndReturnVideoDimensions(constraints) {
    let stream;
    try {
      stream = await navigator.mediaDevices.getUserMedia(constraints);
    } catch (err) {
      throw new Error('GetUserMedia call failed with code ' + error.code);
    }
    var localView = $('local-view');
    localView.srcObject = stream;
    await detectVideoPlaying('local-view');
    return localView.videoWidth + 'x' + localView.videoHeight;
  }
  </script>
</head>
<body>
  <table border="0">
    <tr>
      <td><video id="local-view" autoplay="autoplay">
          </video></td>
      <td><canvas id="local-view-canvas" style="display:none"></canvas></td>
    </tr>
  </table>
</body>
</html>