diff --git a/public/app.js b/public/app.js index 3027942..94bcd4d 100644 --- a/public/app.js +++ b/public/app.js @@ -94,26 +94,21 @@ function renderLiveGrid() { // ── Focus Overlay ── let focusIdx = -1; -let focusTimer = null; function openFocus(cam) { focusIdx = cameras.indexOf(cam); const overlay = document.getElementById('focus-overlay'); overlay.classList.remove('hidden'); updateFocus(); renderThumbs(); - // Refresh snapshot every 500ms for smooth near-live view. - focusTimer = setInterval(updateFocus, 500); } function updateFocus() { if (focusIdx < 0 || focusIdx >= cameras.length) return; const cam = cameras[focusIdx]; document.getElementById('focus-title').textContent = cam.name; - document.getElementById('focus-time').textContent = new Date().toLocaleTimeString(); - // Use the latest.jpg directly — updated every 2s by snapshot engine. - // Fast 500ms refresh gives smooth enough monitoring. - const vid = document.getElementById('focus-video'); - vid.style.display = 'block'; - vid.poster = `/recordings/${cam.name || cam.id}/latest.jpg?t=${Date.now()}`; + document.getElementById('focus-time').textContent = new Date().toLocaleTimeString() + ' live'; + // go2rtc MJPEG stream — real live video via tag, works in all browsers. + const img = document.getElementById('focus-video'); + img.src = `http://${location.hostname}:1984/api/stream.mjpeg?src=${cam.id}_sub`; } function renderThumbs() { const strip = document.getElementById('focus-thumbs'); @@ -129,7 +124,6 @@ function renderThumbs() { } document.getElementById('focus-close').addEventListener('click', () => { document.getElementById('focus-overlay').classList.add('hidden'); - if (focusTimer) { clearInterval(focusTimer); focusTimer = null; } }); document.getElementById('focus-prev').addEventListener('click', () => { if (focusIdx > 0) { focusIdx--; updateFocus(); renderThumbs(); } @@ -141,7 +135,6 @@ document.addEventListener('keydown', e => { if (document.getElementById('focus-overlay').classList.contains('hidden')) return; if (e.key === 'Escape') { document.getElementById('focus-overlay').classList.add('hidden'); - if (focusTimer) { clearInterval(focusTimer); focusTimer = null; } } if (e.key === 'ArrowLeft' && focusIdx > 0) { focusIdx--; updateFocus(); renderThumbs(); } if (e.key === 'ArrowRight' && focusIdx < cameras.length - 1) { focusIdx++; updateFocus(); renderThumbs(); } diff --git a/public/index.html b/public/index.html index db0ff28..3214c7e 100644 --- a/public/index.html +++ b/public/index.html @@ -29,7 +29,7 @@ - + Live stream