Open History to see the last commit
1import { useState } from "react";
2import { View } from "react-native";
3
4import { EmptyState } from "../../components/EmptyState";
5import { MediaVideoPlayer } from "../../components/MediaVideoPlayer";
6import { VideoPreviewModal, type VideoPreviewSource } from "../../components/VideoPreviewModal";
7import type { MediaVideoPreviewSource } from "../../lib/videoPreviewSource";
8
9/** Uses the signed progressive URL directly; choosing a file never preloads its video bytes as text. */
10export function WorkspaceFileVideoPreview(props: {
11 readonly name: string;
12 readonly thumbnailKey: string;
13 readonly uri: string | null;
14 readonly source: MediaVideoPreviewSource | null;
15 readonly resolvePlaybackUri: () => Promise<string | null>;
16 readonly unavailable: boolean;
17}) {
18 const [preview, setPreview] = useState<VideoPreviewSource | null>(null);
19 const uri = props.uri;
20
21 if (props.unavailable) {
22 return (
23 <View className="flex-1 items-center justify-center bg-sheet px-6">
24 <EmptyState
25 title="Video unavailable"
26 detail="This file may be missing, unsupported, or unavailable on this environment."
27 />
28 </View>
29 );
30 }
31
32 return (
33 <View className="flex-1 items-center justify-center bg-sheet p-4">
34 <MediaVideoPlayer
35 uri={uri}
36 resolvePlaybackUri={props.resolvePlaybackUri}
37 name={props.name}
38 thumbnailKey={props.thumbnailKey}
39 actionsSource={props.source?.actionsSource}
40 onExpand={
41 uri === null || props.source === null ? undefined : () => setPreview(props.source)
42 }
43 />
44 <VideoPreviewModal source={preview} onRequestClose={() => setPreview(null)} />
45 </View>
46 );
47}