|
|
@ -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();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
})
|
|
|
|
})
|
|
|
|