From acd88c894e9a89834307f0731d69071cb6c55cf7 Mon Sep 17 00:00:00 2001 From: Gregory Benner Date: Fri, 26 Jan 2018 11:19:33 -0500 Subject: [PATCH] catch and pass on error when trying to play video without a valid source (NotSupportedError) --- src/input/camera_access.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/input/camera_access.js b/src/input/camera_access.js index 9d2d0f4..918837a 100644 --- a/src/input/camera_access.js +++ b/src/input/camera_access.js @@ -40,15 +40,14 @@ function waitForVideo(video) { function initCamera(video, constraints) { return getUserMedia(constraints) .then((stream) => { - return new Promise((resolve) => { + return new Promise((resolve, reject) => { streamRef = stream; video.setAttribute("autoplay", true); video.setAttribute('muted', true); video.setAttribute('playsinline', true); video.srcObject = stream; video.addEventListener('loadedmetadata', () => { - video.play(); - resolve(); + video.play().then(resolve).catch(reject); }); }); })