Skip to content

feat(files): add video preview support - #664

Open
ly2601620664 wants to merge 1 commit into
agegr:mainfrom
ly2601620664:feat/video-preview
Open

feat(files): add video preview support#664
ly2601620664 wants to merge 1 commit into
agegr:mainfrom
ly2601620664:feat/video-preview

Conversation

@ly2601620664

Copy link
Copy Markdown

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: add VIDEO_EXT_TO_MIME (mp4/m4v/webm/mov/ogv) plus getVideoMime() and isVideoPath(). Move .webm out of AUDIO_EXT_TO_MIME (weba stays audio) so WebM videos are no longer misdetected as audio.
  • app/api/files/[...path]/route.ts: route video files through the existing streamFile() path for read, download, and meta. 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 a VideoViewer component mirroring AudioViewer (live watch badge, duration, file size, download button) and route video paths to it. The player is centered with objectFit: contain so portrait videos fit.
  • lib/file-types.test.mjs: cover video detection and the webm/weba disambiguation.

Verification

  • node --test lib/file-types.test.mjs (video + webm/weba tests pass)
  • node_modules/.bin/tsc --noEmit (exit 0)
  • ESLint on the changed files (exit 0)
  • node --test app/api/files/*.test.mjs and components/FileViewer.test.mjs pass

Note: 3 unrelated tests in lib/ fail on Windows in this checkout (symlink EPERM and a PATH-separator comparison) and also fail on the clean baseline before this change.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant