catch and pass on error when trying to play video without a valid source (NotSupportedError)

pull/259/head
Gregory Benner 8 years ago
parent c638c8123c
commit acd88c894e
No known key found for this signature in database
GPG Key ID: 20AAFB5935109E08

@ -40,15 +40,14 @@ function waitForVideo(video) {
function initCamera(video, constraints) { function initCamera(video, constraints) {
return getUserMedia(constraints) return getUserMedia(constraints)
.then((stream) => { .then((stream) => {
return new Promise((resolve) => { return new Promise((resolve, reject) => {
streamRef = stream; streamRef = stream;
video.setAttribute("autoplay", true); video.setAttribute("autoplay", true);
video.setAttribute('muted', true); video.setAttribute('muted', true);
video.setAttribute('playsinline', true); video.setAttribute('playsinline', true);
video.srcObject = stream; video.srcObject = stream;
video.addEventListener('loadedmetadata', () => { video.addEventListener('loadedmetadata', () => {
video.play(); video.play().then(resolve).catch(reject);
resolve();
}); });
}); });
}) })

Loading…
Cancel
Save