feat(files): add video preview support - #664
Open
ly2601620664 wants to merge 1 commit into
Open
Conversation
Add video preview to the file panel, resolving missing support for recordings produced by tools like agent-browser. - Add VIDEO_EXT_TO_MIME (mp4/m4v/webm/mov/ogv), getVideoMime() and isVideoPath() to lib/file-types.ts. Move .webm out of the audio table (weba stays audio) so WebM videos are no longer misdetected as audio. - Route video files through the existing streamFile() path in /api/files/[...path] for read/download/meta, which supports HTTP Range requests (seekable, no size cap). - Add a VideoViewer component mirroring AudioViewer (live watch badge, duration, file size, download) and route video paths to it. - Extend lib/file-types.test.mjs to cover video detection and the webm/weba disambiguation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds native video preview to the file panel, addressing #654. Recordings produced by tools like
agent-browser(mp4/webm) could not be reviewed in Pi Web even though images could.Changes
lib/file-types.ts: addVIDEO_EXT_TO_MIME(mp4/m4v/webm/mov/ogv) plusgetVideoMime()andisVideoPath(). Move.webmout ofAUDIO_EXT_TO_MIME(webastays audio) so WebM videos are no longer misdetected as audio.app/api/files/[...path]/route.ts: route video files through the existingstreamFile()path forread,download, andmeta.streamFile()already supports HTTP Range requests, so videos are streamable, seekable, and not subject to the 256 KB text-preview cap.components/FileViewer.tsx: add aVideoViewercomponent mirroringAudioViewer(live watch badge, duration, file size, download button) and route video paths to it. The player is centered withobjectFit: containso portrait videos fit.lib/file-types.test.mjs: cover video detection and thewebm/webadisambiguation.Verification
node --test lib/file-types.test.mjs(video + webm/weba tests pass)node_modules/.bin/tsc --noEmit(exit 0)node --test app/api/files/*.test.mjsandcomponents/FileViewer.test.mjspassNote: 3 unrelated tests in
lib/fail on Windows in this checkout (symlinkEPERMand a PATH-separator comparison) and also fail on the clean baseline before this change.