Fix web player single-video loop and service worker cache errors

- Loop single-video playlists natively instead of destroying/recreating the element
- Skip caching HTTP 206 partial responses in service worker (video range requests)
- Bump service worker cache version to invalidate old cache

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
ScreenTinker 2026-04-08 12:58:43 -05:00
parent d67dd41056
commit d18045a386
2 changed files with 4 additions and 3 deletions

View file

@ -539,7 +539,8 @@
video.playsInline = true; video.playsInline = true;
video.crossOrigin = 'anonymous'; video.crossOrigin = 'anonymous';
video.style.cssText = 'width:100%;height:100%;object-fit:contain;background:#000'; video.style.cssText = 'width:100%;height:100%;object-fit:contain;background:#000';
video.onended = () => nextItem(); video.loop = (playlist.length === 1);
video.onended = () => { if (!video.loop) nextItem(); };
video.onerror = (e) => { console.error('Video error:', src, e); setTimeout(nextItem, 3000); }; video.onerror = (e) => { console.error('Video error:', src, e); setTimeout(nextItem, 3000); };
video.onloadeddata = () => { video.onloadeddata = () => {
console.log('Video loaded:', item.filename, 'muted:', video.muted); console.log('Video loaded:', item.filename, 'muted:', video.muted);

View file

@ -1,4 +1,4 @@
const CACHE_NAME = 'rd-player-v1'; const CACHE_NAME = 'rd-player-v2';
const STATIC_ASSETS = ['/player/', '/player/index.html', '/socket.io/socket.io.js']; const STATIC_ASSETS = ['/player/', '/player/index.html', '/socket.io/socket.io.js'];
// Install: cache static assets // Install: cache static assets
@ -29,7 +29,7 @@ self.addEventListener('fetch', (event) => {
caches.match(event.request).then(cached => { caches.match(event.request).then(cached => {
if (cached) return cached; if (cached) return cached;
return fetch(event.request).then(response => { return fetch(event.request).then(response => {
if (response.ok) { if (response.ok && response.status === 200) {
const clone = response.clone(); const clone = response.clone();
caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone)); caches.open(CACHE_NAME).then(cache => cache.put(event.request, clone));
} }