From b50cd63dac35d28e720ccad58efa7ded80dee185 Mon Sep 17 00:00:00 2001 From: Neil Gershenfeld <gersh@cba.mit.edu> Date: Sat, 6 Jan 2018 13:52:49 -0500 Subject: [PATCH] new video call --- modules/input/video | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/modules/input/video b/modules/input/video index 4116b3b..1cb52e6 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) -- GitLab