html – Problems with the camera in javascript

window.addEventListener (& # 39; load & # 39; init);

function init () {
var video = document.querySelector (###),
canvas = document.querySelector (###),
btn = document.querySelector ("# t"),
img = document.querySelector (# img #);

navigator.getUserMedia = (navigator.getUserMedia "http://es.stackoverflow.com/" navigator.webkitGetUserMedia "http://es.stackoverflow.com/" navigator.mozGetUSerMedia "http://es.stackoverflow.com/" navigator.msGetUserMedia);

if (navigator.getUserMedia) {
navigator.getUserMedia ({
video: true
}, function (flow) {
video.src = window.URL.createObjectURL (stream);
video.play ();
}, function (e) {
console.log (e)
});

video.addEventListener (Loadmetadata, function () {
canvas.width = video.videoWidth, canvas.height = video.videoHeight;
}, false);
btn.addEventListener ('click', function () {
canvas.getContext ('2d'). drawImage (video, 0, 0);
var imgData = canvas.toDataURL ('image / png');
img.setAttribute (& # 39; src & # 39 ;, imgData);

});

} other {
alert ("actualize tu nvegador");

}

}