Skip to content

Instantly share code, notes, and snippets.

@radermacher
Last active August 29, 2015 14:01
Show Gist options
  • Save radermacher/037472757f5e84e63e1c to your computer and use it in GitHub Desktop.
Save radermacher/037472757f5e84e63e1c to your computer and use it in GitHub Desktop.
WebRTC Sample - Demo: http://jsbin.com/goqes/1/watch
<html>
<head>
<title>Web RTC</title>
<style type="text/css">
video {
-webkit-transform: scaleX(-1);
transform: scaleX(-1);
}
video {
width: 100%;
}
</style>
</head>
<body>
<video autoplay></video>
<script type="text/javascript">
navigator.getUserMedia = navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia ||
false;
var video = document.querySelector('video');
var hdConstraints = {
video : {
mandatory: {
minWidth: 1280,
minHeight: 720
}
}
};
var errorCallback = function(e) {
console.log('Rejected!', e);
};
var successCallback = function(stream) {
video.src = window.URL.createObjectURL(stream);
video.width = hdConstraints.video.mandatory.minWidth;
video.height = hdConstraints.video.mandatory.minHeight;
}
if (navigator.getUserMedia) {
navigator.getUserMedia(hdConstraints, successCallback, errorCallback);
}
else {
console.log('not supported');
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment