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) {
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);
});
});
})

Loading…
Cancel
Save