diff --git a/public/app.js b/public/app.js index 0005556..fa24f3f 100644 --- a/public/app.js +++ b/public/app.js @@ -106,10 +106,23 @@ function updateFocus() { const cam = cameras[focusIdx]; document.getElementById('focus-title').textContent = cam.name; document.getElementById('focus-time').textContent = new Date().toLocaleTimeString() + ' live'; - // go2rtc MSE stream for full-quality playback. + + // go2rtc WebRTC player — works in all browsers. const vid = document.getElementById('focus-video'); - vid.src = `http://${location.hostname}:1984/api/stream.m3u8?src=${cam.id}_main`; - vid.play().catch(() => {}); + const streamURL = `http://${location.hostname}:1984/stream.html?src=${cam.id}_main&mode=webrtc`; + // Use iframe for proper WebRTC support. + const container = vid.parentElement; + // Replace video element with iframe for go2rtc's player. + let iframe = container.querySelector('iframe.go2rtc-player'); + if (!iframe) { + iframe = document.createElement('iframe'); + iframe.className = 'go2rtc-player'; + iframe.allow = 'autoplay; camera; microphone'; + iframe.style.cssText = 'width:100%;height:100%;border:none;position:absolute;inset:0'; + vid.style.display = 'none'; + container.appendChild(iframe); + } + iframe.src = streamURL; } function renderThumbs() { const strip = document.getElementById('focus-thumbs');