Revert to MJPEG stream for camera - works perfectly in browser
This commit is contained in:
parent
42b0d611f6
commit
b75a3185da
15
index.html
15
index.html
|
|
@ -348,21 +348,20 @@ function isCamTime() {
|
||||||
return h >= 19 || h < 8;
|
return h >= 19 || h < 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Double-buffer: load in hidden img, swap on load (no flicker)
|
function updateCam() {
|
||||||
const bufImg = new Image();
|
|
||||||
bufImg.onload = () => { camImg.src = bufImg.src; };
|
|
||||||
|
|
||||||
function refreshCam() {
|
|
||||||
if (isCamTime()) {
|
if (isCamTime()) {
|
||||||
camWrap.style.display = '';
|
camWrap.style.display = '';
|
||||||
bufImg.src = '/api/cam/pulse-ox?' + Date.now();
|
if (!camImg.src.includes('/stream')) {
|
||||||
|
camImg.src = '/api/cam/pulse-ox/stream';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
camWrap.style.display = 'none';
|
camWrap.style.display = 'none';
|
||||||
|
camImg.src = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshCam();
|
updateCam();
|
||||||
setInterval(refreshCam, 1000);
|
setInterval(updateCam, 60000);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue