Created
November 24, 2015 07:27
-
-
Save Dishwasha/b25f6dd3179732033d5c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>IFC - WebRTC getUserMedia Test</title> | |
<meta charset="UTF-8"/> | |
<link href='http://fonts.googleapis.com/css?family=Fauna+One' rel='stylesheet' type='text/css'> | |
<link rel="stylesheet" href="https://rawgit.com/skeelogy/ifc-ar-flood/master/css/style.css"> | |
<!--load helper libraries--> | |
<script src="https://rawgit.com/skeelogy/ifc-ar-flood/master/js/lib/jquery-2.0.2.min.js"></script> | |
<!--official WebRTC's polyfill for handling cross-browser differences--> | |
<script type="text/javascript" src="https://rawgit.com/skeelogy/ifc-ar-flood/master/js/lib/webrtc_adapter.js"></script> | |
<script> | |
$(document).ready(function () { | |
console.log('Document is ready.'); | |
//use getUserMedia() to stream the webcam video | |
var video = $('#mainVideo')[0]; | |
if (getUserMedia) { | |
console.log("Calling getUserMedia()..."); | |
getUserMedia( | |
{'audio': false, 'video': true}, | |
function (localMediaStream) { | |
console.log("User has granted access to local media."); | |
var localMediaStreamUrl = URL.createObjectURL(localMediaStream); | |
console.log('Local media stream URL: ' + localMediaStreamUrl); | |
//call wrapper to attach the media stream to the video element | |
console.log('Attaching local media stream...'); | |
attachMediaStream(video, localMediaStream); | |
console.log('Done.'); | |
}, | |
function (error) { | |
var errorMsg = 'ERROR: getUserMedia(): ' + JSON.stringify(error); | |
console.error(errorMsg); | |
alert(errorMsg); | |
} | |
); | |
} else { | |
var errorMsg = 'ERROR: Your browser does not support getUserMedia()'; | |
console.error(errorMsg); | |
alert(errorMsg); | |
} | |
}); | |
</script> | |
</head> | |
<body> | |
<h2>WebRTC getUserMedia()</h2> | |
<div class="container" id="video-container"> | |
<div class="caption"><video></div> | |
<video id="mainVideo" width="640" height="480" autoplay="autoplay" muted="true"></video> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment