webcam = {
if (enableWebcam) {
const stream = navigator.mediaDevices
? navigator.mediaDevices.getUserMedia({video: true})
: new Promise((y, n) => navigator.getUserMedia({video: true}, y, n));
const video = html`<video width=227 height=227 autoplay=true playsinline=true></video>`;
video.style.maxWidth = "100%";
const vid = await stream.then(stream => {
if ("srcObject" in video) video.srcObject = stream;
else video.src = URL.createObjectURL(stream);
invalidation.then(() => {
stream.getTracks().forEach(t => t.stop());
URL.revokeObjectURL(video.src);
});
return video;
});
return vid;
}
}