Revert to MJPEG stream for camera - works perfectly in browser

This commit is contained in:
James 2026-02-14 02:27:15 -05:00
parent 42b0d611f6
commit b75a3185da
1 changed files with 7 additions and 8 deletions

View File

@ -348,21 +348,20 @@ function isCamTime() {
return h >= 19 || h < 8;
}
// Double-buffer: load in hidden img, swap on load (no flicker)
const bufImg = new Image();
bufImg.onload = () => { camImg.src = bufImg.src; };
function refreshCam() {
function updateCam() {
if (isCamTime()) {
camWrap.style.display = '';
bufImg.src = '/api/cam/pulse-ox?' + Date.now();
if (!camImg.src.includes('/stream')) {
camImg.src = '/api/cam/pulse-ox/stream';
}
} else {
camWrap.style.display = 'none';
camImg.src = '';
}
}
refreshCam();
setInterval(refreshCam, 1000);
updateCam();
setInterval(updateCam, 60000);
</script>
</body>
</html>