Async gUM getSettings width height

by Abhijeet Kandalkar

HTML

<script src="https://webrtc.github.io/adapter/adapter-latest.js"></script>
<div id="div"></div>
<video id="video" autoplay></video>

JavaScript

var console = { log: msg => div.innerHTML += msg + "<br>" };

function showSettings() {

}

(async () => {
  try {
    let constraints = {video: {width: 300}};
    video.srcObject = await navigator.mediaDevices.getUserMedia(constraints);
    let track = video.srcObject.getTracks()[0];
    if (track.getSettings) {
      let {width, height, frameRate} = track.getSettings();
      console.log("Track settings : " + `${width}x${height}x${frameRate}`);
    }
    await new Promise(resolve => video.onloadedmetadata = resolve);
    console.log("Video element dimensions : " + `${video.videoWidth}x${video.videoHeight}`);
  } catch(e) {
    console.log(e);
  }
})();