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; 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>