From 11e697915ee2e6287c4362a94190fc3544b44d23 Mon Sep 17 00:00:00 2001 From: robot Date: Wed, 12 Aug 2026 08:59:11 +0000 Subject: [PATCH] fix(viewer): fallback to src as HLS manifest when hlsManifest is missing When mediaType=hls but hlsManifest field is absent (e.g. lost during storage serialization), fall back to src if it looks like a manifest URL (.m3u8 with http scheme). This prevents the video from silently failing to play on Chrome where there is no native HLS support. --- src/viewer/viewer.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/viewer/viewer.js b/src/viewer/viewer.js index 606c8b6..2795928 100644 --- a/src/viewer/viewer.js +++ b/src/viewer/viewer.js @@ -642,18 +642,27 @@ function createPanel(entry, tag) { if (poster) video.poster = poster; - if (mediaType === 'hls' && hlsManifest) { - video.dataset.hlsManifest = hlsManifest; - video.dataset.mediaType = 'hls'; - console.log('[goon-viewer] HLS detected, manifest:', hlsManifest); - panel.appendChild(video); - if (tag) { - const label = document.createElement('div'); - label.className = 'panel-label'; - label.textContent = tag; - panel.appendChild(label); + if (mediaType === 'hls') { + // Use explicit hlsManifest field, or fall back to src if it looks like a manifest URL. + // This handles the case where hlsManifest was lost in storage serialization but src + // still points to the .m3u8 playlist. + const manifestUrl = hlsManifest || (src.includes('.m3u8') && src.startsWith('http') ? src : null); + if (manifestUrl) { + video.dataset.hlsManifest = manifestUrl; + video.dataset.mediaType = 'hls'; + console.log('[goon-viewer] HLS detected, manifest:', manifestUrl); + panel.appendChild(video); + if (tag) { + const label = document.createElement('div'); + label.className = 'panel-label'; + label.textContent = tag; + panel.appendChild(label); + } + return { panel, hlsEntry: { video, manifest: manifestUrl, panel } }; } - return { panel, hlsEntry: { video, manifest: hlsManifest, panel } }; + // mediaType says HLS but we have no manifest URL — fall through to native playback. + // On Safari this may still work for .m3u8; on Chrome it will fail. + console.warn('[goon-viewer] HLS entry missing manifest URL, src:', src); } video.src = src;