I'm trying to get Chrome's getUserMedia to work on my localhost.
My index.php file is:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/script.js"></script>
<title></title>
</head>
<body>
<video id="MediaStreamVideo" autoplay=""></video>
</body>
</html>
My script.js file is:
var stream;
var video = document.getElementById('MediaStreamVideo');
navigator.webkitGetUserMedia(
{video: true, audio: true}, // Options
function(localMediaStream) { // Success
stream = localMediaStream;
video.src = window.webkitURL.createObjectURL(stream);
},
function(err) { // Failure
alert('getUserMedia failed: Code ' + err.code);
}
);
Chrome asks me to allow using the camera and microphone (which I accept), but then nothing happens.
It works fine on jsfidde
Any ideas?