<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Stream API</title>
  <style>
    section {
      float: left;
    }
  </style>
  <script>
    async function initiate() {
      const video = document.getElementById("video");
      const databox = document.getElementById("databox");
      try {
        const stream = await navigator.mediaDevices.getUserMedia({video: true});
        video.srcObject = stream;
        video.play();

        const videoTracks = stream.getVideoTracks();
        const track = videoTracks[0];
        let data = "";
        data += "<br> Enabled: " + track.enabled;
        data += "<br> Type: " + track.kind;
        data += "<br> Device: " + track.label;
        databox.innerHTML = data;
      } catch (error) {
        console.log("Error: " + error.name);
      }
    }
    window.addEventListener("DOMContentLoaded", initiate);
  </script>
</head>
<body>
  <section>
    <video id="video"></video>
  </section>
  <section id="databox"></section>
</body>
</html>