fix(viewer): fallback to src as HLS manifest when hlsManifest is missing
CI / test (pull_request) Successful in 19s
CI / test (pull_request) Successful in 19s
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.
This commit is contained in:
1 parent
02498f2694
commit
11e697915e
1 file changed
+13
-4
+13
-4
@@ -642,10 +642,15 @@ function createPanel(entry, tag) {
|
|||||||
|
|
||||||
if (poster) video.poster = poster;
|
if (poster) video.poster = poster;
|
||||||
|
|
||||||
if (mediaType === 'hls' && hlsManifest) {
|
if (mediaType === 'hls') {
|
||||||
video.dataset.hlsManifest = hlsManifest;
|
// 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';
|
video.dataset.mediaType = 'hls';
|
||||||
console.log('[goon-viewer] HLS detected, manifest:', hlsManifest);
|
console.log('[goon-viewer] HLS detected, manifest:', manifestUrl);
|
||||||
panel.appendChild(video);
|
panel.appendChild(video);
|
||||||
if (tag) {
|
if (tag) {
|
||||||
const label = document.createElement('div');
|
const label = document.createElement('div');
|
||||||
@@ -653,7 +658,11 @@ function createPanel(entry, tag) {
|
|||||||
label.textContent = tag;
|
label.textContent = tag;
|
||||||
panel.appendChild(label);
|
panel.appendChild(label);
|
||||||
}
|
}
|
||||||
return { panel, hlsEntry: { video, manifest: hlsManifest, panel } };
|
return { panel, hlsEntry: { video, manifest: manifestUrl, 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;
|
video.src = src;
|
||||||
|
|||||||
Reference in new issue
Block a user