({ model }: SpecializedViewProps)
| 47 | } |
| 48 | |
| 49 | function 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 | |
| 92 | export { StreamingPreview }; |
nothing calls this directly
no test coverage detected