Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"></script>
  <meta charset="utf-8">
  <title>JS Bin</title>
</head>
<body>
  
  <video src="" id="video"></video><br>
  
  <button id="2048">Minimal width 2048</button>
  <button id="1600">Minimal width 1600</button>
</body>
</html>
 
var getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia;
var URL = window.URL || window.webkitURL;
var currentStream;
$('#video').on('loadeddata', function() {
  var video = this;
  this.play();
  setTimeout(function() {
    console.log(video.videoWidth, video.videoHeight);
  }, 1000);
});
function close() {
  if (currentStream) {
    currentStream.stop();
  }
}
function run(minWidth) {
  var constraints = {
    video: {
      optional: [
        {minWidth: minWidth}
      ]
    }
  };
  getUserMedia.call(navigator, constraints, function(stream) {
    currentStream = stream;
    $('#video').prop('src', URL.createObjectURL(stream));
    $('#video')[0].play();
  }, function() {
    alert('failed');
  });
}
$('#2048').on('click', function() {
  close();
  run(2048);
});
$('#1600').on('click', function() {
  close();
  run(1600);
});
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
hommpro
0viewers