diff --git a/modules/input/video b/modules/input/video index 4116b3b8024c2a6691b6103f5ebf5c11fa110c38..1cb52e68fe19cef7f62106d3495b68012c72303c 100644 --- a/modules/input/video +++ b/modules/input/video @@ -146,26 +146,20 @@ function start_video() { var ctx = mod.img.getContext("2d") ctx.canvas.width = w ctx.canvas.height = h - navigator.getMedia = ( - navigator.getUserMedia || - navigator.webkitGetUserMedia || - navigator.mozGetUserMedia || - navigator.msGetUserMedia) - navigator.getMedia( - {video:true,audio:false}, - function(stream) { - var vendorURL = window.URL || window.webkitURL - mod.video.src = vendorURL.createObjectURL(stream) - mod.video.play() - }, - function(err) {console.log("video startup error")} - ) - mod.video.addEventListener('canplay', - function(evt) { - mod.video.setAttribute('width',w) - mod.video.setAttribute('height',h) - capture_video() - }) + var constraints = { + audio:false, + video:{width:w,height:h} + } + navigator.mediaDevices.getUserMedia(constraints) + .then(function(stream) { + mod.video.srcObject = stream + mod.video.onloadedmetadata = function(e) { + mod.video.play() + } + }) + .catch(function(err) { + console.log(err.name + ": "+err.message) + }) } function update_video() { var w = parseInt(mod.width.value)