feat: support mobile video previews

This commit is contained in:
TerryM
2026-06-01 16:35:40 +08:00
parent c53032155b
commit a968f47640
16 changed files with 275 additions and 47 deletions

View File

@@ -9,6 +9,7 @@ import {
} from "react";
import type { Attachment } from "../../types/post";
import { AttachmentDownloadPill } from "./AttachmentDownloadPill";
import { useVideoPreviewSource } from "./hooks/useVideoPreviewSource";
import { useVideoPlayer } from "./overlays/VideoPlayer";
function pad2(n: number): string {
@@ -127,6 +128,7 @@ export function MessageInlineVideo({
const [snapProgress, setSnapProgress] = useState(false);
const t = TOKENS[size];
const videoSrc = useVideoPreviewSource(attachment);
useEffect(() => {
const v = videoRef.current;
@@ -270,7 +272,7 @@ export function MessageInlineVideo({
<>
<video
ref={videoRef}
src={attachment.url}
src={videoSrc}
poster={attachment.posterUrl}
playsInline
autoPlay={autoPlay}