MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / StreamingPreview

Function StreamingPreview

frontend/app/view/preview/preview-streaming.tsx:49–90  ·  view source on GitHub ↗
({ model }: SpecializedViewProps)

Source from the content-addressed store, hash-verified

47}
48
49function StreamingPreview({ model }: SpecializedViewProps) {
50 useEffect(() => {
51 model.refreshCallback = () => {
52 globalStore.set(model.refreshVersion, (v) => v + 1);
53 };
54 return () => {
55 model.refreshCallback = null;
56 };
57 }, []);
58 const conn = useAtomValue(model.connection);
59 const fileInfo = useAtomValue(model.statFile);
60 const filePath = fileInfo.path;
61 const remotePath = formatRemoteUri(filePath, conn);
62 const usp = new URLSearchParams();
63 usp.set("path", remotePath);
64 const streamingUrl = `${getWebServerEndpoint()}/wave/stream-file?${usp.toString()}`;
65 if (fileInfo.mimetype === "application/pdf") {
66 return (
67 <div className="flex flex-row h-full overflow-hidden items-center justify-center p-[5px]">
68 <iframe src={streamingUrl} width="100%" height="100%" name="pdfview" />
69 </div>
70 );
71 }
72 if (fileInfo.mimetype.startsWith("video/")) {
73 return (
74 <div className="flex flex-row h-full overflow-hidden items-center justify-center">
75 <video controls src={streamingUrl} className="w-full h-full p-[10px] object-contain" />
76 </div>
77 );
78 }
79 if (fileInfo.mimetype.startsWith("audio/")) {
80 return (
81 <div className="flex flex-row h-full overflow-hidden items-center justify-center">
82 <audio controls src={streamingUrl} className="w-full h-full p-[10px] object-contain" />
83 </div>
84 );
85 }
86 if (fileInfo.mimetype.startsWith("image/")) {
87 return <StreamingImagePreview url={streamingUrl} />;
88 }
89 return <CenteredDiv>Preview Not Supported</CenteredDiv>;
90}
91
92export { StreamingPreview };

Callers

nothing calls this directly

Calls 2

formatRemoteUriFunction · 0.90
setMethod · 0.80

Tested by

no test coverage detected