Merge branch 'feat/streaming-client-prefetch-split'
@@ -175,7 +175,7 @@
175
175
- Standalone public share page served at /share/:token; no auth required.
176
176
- Timer bar - Live HH:MM:SS countdown showing remaining validity; turns red and disables download when expired.
177
177
- tryPreview(name, isDir) - Renders inline preview (img/video/audio/text pre); no-op for unsupported types or directories.
178
- Share video preview - Uses the shared browser video-player helper used by app previews: VOD UI enforcement, long forward buffer, forced caption overrides (text background opacity transparent + text edge style uniform), subtitle/audio track restore/save by matching track names, image-subtitle overlay support, service-worker-backed HLS segment cache enablement during playback (with per-session cache cleanup on close), and explicit backend session release on unload.
178
- Share video preview - Uses the shared browser video-player helper used by app previews: VOD UI enforcement, long forward buffer, forced caption overrides (text background opacity transparent + text edge style uniform), subtitle/audio track restore/save by matching track names, image-subtitle overlay support, background stream-ahead prefetch (session playlist/variant/segment fetches continue towards video end while playback reads cache), service-worker-backed HLS segment cache enablement during playback (with per-session cache cleanup on close), and explicit backend session release on unload.
179
179
- Fetches /api/share/info/:token on load; shows error state for 404/410 responses.
180
180
- Download link points to /api/share/download/:token; labelled "Download als .zip" for directories.
181
181
@@ -183,6 +183,7 @@
183
183
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
184
184
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
185
185
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, keeps a separate rolling lookahead-prefetch worker alive across timeupdates (including gaps where no subtitle is currently visible), extends prefetch target to at least the latest buffered video end (not only fixed lookahead seconds), merges buffered-end signals from both Video.js/player APIs and underlying media buffered ranges so under-reported player values do not cap subtitle prefetch early, keeps the prefetch frontier pinned to at least current playback time so it chases buffered-ahead range instead of replaying stale lag after video/session changes, coalesces overlapping current-frame refreshes into a single in-flight fetch (only force-refresh paths abort/restart), applies per-request timeouts (`currentRequestTimeoutMs`, `prefetchRequestTimeoutMs`) so hung subtitle frame requests cannot stall updates indefinitely, paces prefetch polling (`prefetchRequestIntervalMs`) to reduce request bursts, logs current and prefetch subtitle request/send/receive/not-available timing to the browser console and optional batch sink, caches received subtitle PNG frames client-side for the lifetime of the player session (including prefetched frames) so rewind playback can render from local cache even after server-side purge, ensures force-seek aborts still clear in-flight current-request state so subtitle refreshes continue instead of deadlocking, updates seek-bar bracket markers only after responses resolve (no in-flight jump-back flicker), keeps both marker positions forward-only (never regressing to earlier times), allows the two bracket glyphs to overlap naturally when positions match, advances markers even when responses are 204/no-frame, and disables the track after the first hard failure.
186
- bindStreamAheadPrefetch(opts) - Starts a background HLS walker that repeatedly fetches the session playlist, discovers variant playlists and media segments, and prefetches those assets into the browser cache so playback can read already-fetched segments while the backend prunes old files; returns a controller with stop()/done().
186
187
- enableVideoStreamClientCache() - Registers a shared service worker (`/stream-cache-sw.js`) that caches HLS playlist/segment responses so already-downloaded stream assets remain playable on rewind after server-side segment pruning.
187
188
- clearVideoStreamClientCache(playlistUrl) - Best-effort cache cleanup helper that removes cached HLS entries for one stream session when preview playback is closed.
188
189
@@ -258,6 +259,7 @@
258
259
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
259
260
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
260
261
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
262
- renderStreamedVideoPreview(item) - For authenticated video previews, creates a backend stream session and starts the background stream-ahead prefetch worker so playlist/segment requests can continue independently of playback reads until cleanup.
261
263
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; keeps subtitle bitmaps horizontally centred at the bottom, highlights the currently selected IM menu option, persists per-user image subtitle stream index + track name, restores by saved track name first (then stream index), batches subtitle timing diagnostics to `/api/files/video-stream-subtitle-log`, and reads X-Subtitle-Frame-* headers from server responses to properly upscale downscaled frames while maintaining proportions.
262
264
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enables service-worker-backed HLS segment caching for the active stream session (and clears that cache on close), enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
263
265
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
@@ -175,7 +175,7 @@175
- Standalone public share page served at /share/:token; no auth required.
175
- Standalone public share page served at /share/:token; no auth required.
176
- Timer bar - Live HH:MM:SS countdown showing remaining validity; turns red and disables download when expired.
176
- Timer bar - Live HH:MM:SS countdown showing remaining validity; turns red and disables download when expired.
177
- tryPreview(name, isDir) - Renders inline preview (img/video/audio/text pre); no-op for unsupported types or directories.
177
- tryPreview(name, isDir) - Renders inline preview (img/video/audio/text pre); no-op for unsupported types or directories.
178
- Share video preview - Uses the shared browser video-player helper used by app previews: VOD UI enforcement, long forward buffer, forced caption overrides (text background opacity transparent + text edge style uniform), subtitle/audio track restore/save by matching track names, image-subtitle overlay support, service-worker-backed HLS segment cache enablement during playback (with per-session cache cleanup on close), and explicit backend session release on unload.
178
- Share video preview - Uses the shared browser video-player helper used by app previews: VOD UI enforcement, long forward buffer, forced caption overrides (text background opacity transparent + text edge style uniform), subtitle/audio track restore/save by matching track names, image-subtitle overlay support, background stream-ahead prefetch (session playlist/variant/segment fetches continue towards video end while playback reads cache), service-worker-backed HLS segment cache enablement during playback (with per-session cache cleanup on close), and explicit backend session release on unload.
179
- Fetches /api/share/info/:token on load; shows error state for 404/410 responses.
179
- Fetches /api/share/info/:token on load; shows error state for 404/410 responses.
180
- Download link points to /api/share/download/:token; labelled "Download als .zip" for directories.
180
- Download link points to /api/share/download/:token; labelled "Download als .zip" for directories.
181
181
@@ -183,6 +183,7 @@183
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
183
- applyDefaultTextTrackPrefs() - Writes the default Video.js caption override settings (transparent background, uniform edge style) so all streamed players start from the same text-track baseline.
184
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
184
- bindTrackPrefs(player, prefs, savePrefs) - Restores subtitle/audio track selections by track name and persists later track changes; shared by the authenticated player and the share page so both resolve track matches the same way.
185
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, keeps a separate rolling lookahead-prefetch worker alive across timeupdates (including gaps where no subtitle is currently visible), extends prefetch target to at least the latest buffered video end (not only fixed lookahead seconds), merges buffered-end signals from both Video.js/player APIs and underlying media buffered ranges so under-reported player values do not cap subtitle prefetch early, keeps the prefetch frontier pinned to at least current playback time so it chases buffered-ahead range instead of replaying stale lag after video/session changes, coalesces overlapping current-frame refreshes into a single in-flight fetch (only force-refresh paths abort/restart), applies per-request timeouts (`currentRequestTimeoutMs`, `prefetchRequestTimeoutMs`) so hung subtitle frame requests cannot stall updates indefinitely, paces prefetch polling (`prefetchRequestIntervalMs`) to reduce request bursts, logs current and prefetch subtitle request/send/receive/not-available timing to the browser console and optional batch sink, caches received subtitle PNG frames client-side for the lifetime of the player session (including prefetched frames) so rewind playback can render from local cache even after server-side purge, ensures force-seek aborts still clear in-flight current-request state so subtitle refreshes continue instead of deadlocking, updates seek-bar bracket markers only after responses resolve (no in-flight jump-back flicker), keeps both marker positions forward-only (never regressing to earlier times), allows the two bracket glyphs to overlap naturally when positions match, advances markers even when responses are 204/no-frame, and disables the track after the first hard failure.
185
- bindImageSubtitleOverlay(player, videojs, prefs, session, opts) - Adds the shared IM button/menu/overlay for bitmap subtitle tracks, restores saved image-subtitle selections, fetches rendered frames through a caller-supplied request builder, keeps a separate rolling lookahead-prefetch worker alive across timeupdates (including gaps where no subtitle is currently visible), extends prefetch target to at least the latest buffered video end (not only fixed lookahead seconds), merges buffered-end signals from both Video.js/player APIs and underlying media buffered ranges so under-reported player values do not cap subtitle prefetch early, keeps the prefetch frontier pinned to at least current playback time so it chases buffered-ahead range instead of replaying stale lag after video/session changes, coalesces overlapping current-frame refreshes into a single in-flight fetch (only force-refresh paths abort/restart), applies per-request timeouts (`currentRequestTimeoutMs`, `prefetchRequestTimeoutMs`) so hung subtitle frame requests cannot stall updates indefinitely, paces prefetch polling (`prefetchRequestIntervalMs`) to reduce request bursts, logs current and prefetch subtitle request/send/receive/not-available timing to the browser console and optional batch sink, caches received subtitle PNG frames client-side for the lifetime of the player session (including prefetched frames) so rewind playback can render from local cache even after server-side purge, ensures force-seek aborts still clear in-flight current-request state so subtitle refreshes continue instead of deadlocking, updates seek-bar bracket markers only after responses resolve (no in-flight jump-back flicker), keeps both marker positions forward-only (never regressing to earlier times), allows the two bracket glyphs to overlap naturally when positions match, advances markers even when responses are 204/no-frame, and disables the track after the first hard failure.
186
- bindStreamAheadPrefetch(opts) - Starts a background HLS walker that repeatedly fetches the session playlist, discovers variant playlists and media segments, and prefetches those assets into the browser cache so playback can read already-fetched segments while the backend prunes old files; returns a controller with stop()/done().
186
- enableVideoStreamClientCache() - Registers a shared service worker (`/stream-cache-sw.js`) that caches HLS playlist/segment responses so already-downloaded stream assets remain playable on rewind after server-side segment pruning.
187
- enableVideoStreamClientCache() - Registers a shared service worker (`/stream-cache-sw.js`) that caches HLS playlist/segment responses so already-downloaded stream assets remain playable on rewind after server-side segment pruning.
187
- clearVideoStreamClientCache(playlistUrl) - Best-effort cache cleanup helper that removes cached HLS entries for one stream session when preview playback is closed.
188
- clearVideoStreamClientCache(playlistUrl) - Best-effort cache cleanup helper that removes cached HLS entries for one stream session when preview playback is closed.
188
189
@@ -258,6 +259,7 @@258
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
259
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
259
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
260
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
260
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
261
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
262
- renderStreamedVideoPreview(item) - For authenticated video previews, creates a backend stream session and starts the background stream-ahead prefetch worker so playlist/segment requests can continue independently of playback reads until cleanup.
261
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; keeps subtitle bitmaps horizontally centred at the bottom, highlights the currently selected IM menu option, persists per-user image subtitle stream index + track name, restores by saved track name first (then stream index), batches subtitle timing diagnostics to `/api/files/video-stream-subtitle-log`, and reads X-Subtitle-Frame-* headers from server responses to properly upscale downscaled frames while maintaining proportions.
263
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; keeps subtitle bitmaps horizontally centred at the bottom, highlights the currently selected IM menu option, persists per-user image subtitle stream index + track name, restores by saved track name first (then stream index), batches subtitle timing diagnostics to `/api/files/video-stream-subtitle-log`, and reads X-Subtitle-Frame-* headers from server responses to properly upscale downscaled frames while maintaining proportions.
262
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enables service-worker-backed HLS segment caching for the active stream session (and clears that cache on close), enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
264
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enables service-worker-backed HLS segment caching for the active stream session (and clears that cache on close), enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
263
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
265
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
@@ -465,6 +465,17 @@ function clearVideoStreamClientCache (playlistUrl)
465
465
return shared.clearVideoStreamClientCache(playlistUrl);
466
466
}
467
467
468
function bindStreamAheadPrefetch (playlistUrl)
469
{
470
const shared = sharedVideoPlayer();
471
if (!shared || typeof shared.bindStreamAheadPrefetch !== 'function') return null;
472
return shared.bindStreamAheadPrefetch({
473
playlistUrl,
474
headers: buildAuthHeaders(),
475
credentials: 'same-origin',
476
});
477
}
478
468
479
async function reportWatchProgress (filePath, progress)
469
480
{
470
481
if (!filePath || !Number.isFinite(progress)) return;
@@ -3924,6 +3935,7 @@ async function renderStreamedVideoPreview (item, targetEl)
3924
3935
await enableVideoStreamClientCache();
3925
3936
const session = await createVideoStreamSessionForItem(item);
3926
3937
const sessionPlaylistUrl = String(session.playlistUrl || '').trim() || null;
3938
const streamAheadPrefetch = bindStreamAheadPrefetch(sessionPlaylistUrl);
3927
3939
STATE.previewVideoStreamSessionId = String(session.sessionId || '').trim() || null;
3928
3940
const prefs = loadUserVideoPrefs();
3929
3941
applyUserVideoTextTrackPrefs();
@@ -4051,6 +4063,7 @@ async function renderStreamedVideoPreview (item, targetEl)
4051
4063
try { imageSubtitleController.captureSelectedTracks(); } catch { /* ignore */ }
4052
4064
try { imageSubtitleController.detach(); } catch { /* ignore */ }
4053
4065
}
4066
try { streamAheadPrefetch && streamAheadPrefetch.stop(); } catch { /* ignore */ }
4054
4067
void clearVideoStreamClientCache(sessionPlaylistUrl);
4055
4068
releaseActivePreviewVideoStreamSession();
4056
4069
try { markWatch(); } catch { /* ignore */ }
@@ -465,6 +465,17 @@ function clearVideoStreamClientCache (playlistUrl)465
return shared.clearVideoStreamClientCache(playlistUrl);465
return shared.clearVideoStreamClientCache(playlistUrl);466
}466
}467
467
468
function bindStreamAheadPrefetch (playlistUrl)469
{470
const shared = sharedVideoPlayer();471
if (!shared || typeof shared.bindStreamAheadPrefetch !== 'function') return null;472
return shared.bindStreamAheadPrefetch({473
playlistUrl,474
headers: buildAuthHeaders(),475
credentials: 'same-origin',476
});477
}478
468
async function reportWatchProgress (filePath, progress)479
async function reportWatchProgress (filePath, progress)469
{480
{470
if (!filePath || !Number.isFinite(progress)) return;481
if (!filePath || !Number.isFinite(progress)) return;@@ -3924,6 +3935,7 @@ async function renderStreamedVideoPreview (item, targetEl)3924
await enableVideoStreamClientCache();3935
await enableVideoStreamClientCache();3925
const session = await createVideoStreamSessionForItem(item);3936
const session = await createVideoStreamSessionForItem(item);3926
const sessionPlaylistUrl = String(session.playlistUrl || '').trim() || null;3937
const sessionPlaylistUrl = String(session.playlistUrl || '').trim() || null;3938
const streamAheadPrefetch = bindStreamAheadPrefetch(sessionPlaylistUrl);3927
STATE.previewVideoStreamSessionId = String(session.sessionId || '').trim() || null;3939
STATE.previewVideoStreamSessionId = String(session.sessionId || '').trim() || null;3928
const prefs = loadUserVideoPrefs();3940
const prefs = loadUserVideoPrefs();3929
applyUserVideoTextTrackPrefs();3941
applyUserVideoTextTrackPrefs();@@ -4051,6 +4063,7 @@ async function renderStreamedVideoPreview (item, targetEl)4051
try { imageSubtitleController.captureSelectedTracks(); } catch { /* ignore */ }4063
try { imageSubtitleController.captureSelectedTracks(); } catch { /* ignore */ }4052
try { imageSubtitleController.detach(); } catch { /* ignore */ }4064
try { imageSubtitleController.detach(); } catch { /* ignore */ }4053
}4065
}4066
try { streamAheadPrefetch && streamAheadPrefetch.stop(); } catch { /* ignore */ }4054
void clearVideoStreamClientCache(sessionPlaylistUrl);4067
void clearVideoStreamClientCache(sessionPlaylistUrl);4055
releaseActivePreviewVideoStreamSession();4068
releaseActivePreviewVideoStreamSession();4056
try { markWatch(); } catch { /* ignore */ }4069
try { markWatch(); } catch { /* ignore */ }