diff --git a/src/app/@preview.audio.tsx b/src/app/@preview.audio.tsx index eaf7e51..ba5d2dc 100644 --- a/src/app/@preview.audio.tsx +++ b/src/app/@preview.audio.tsx @@ -1,7 +1,7 @@ "use client"; +import dynamic from "next/dynamic"; import { useEffect, useState } from "react"; -import AudioPlayer from "react-h5-audio-player"; import "react-h5-audio-player/lib/styles.css"; import { z } from "zod"; import { Schema_File } from "~/schema"; @@ -10,7 +10,27 @@ import { cn } from "~/utils"; import Icon from "~/components/Icon"; import { CreateDownloadToken } from "./actions"; -import "./r5-style.css"; + +// import "./r5-style.css"; + +const Plyr = dynamic(() => import("plyr-react"), { + ssr: false, + loading: () => ( +
+ +

Loading player...

+
+ ), +}); type Props = { file: z.infer; @@ -28,7 +48,7 @@ export default function PreviewAudio({ file }: Props) { return; } const token = await CreateDownloadToken(); - setAudioSrc(`/api/download/${file.encryptedId}?token=${token}`); + setAudioSrc(`/api/stream/${file.encryptedId}?token=${token}`); } catch (error) { const e = error as Error; console.error(e); @@ -66,20 +86,43 @@ export default function PreviewAudio({ file }: Props) { ) : (
- { - console.error(e); - setError( - "Could not preview this audio, try downloading the file", - ); + options={{ + controls: [ + "play-large", + "play", + "progress", + "current-time", + "duration", + "mute", + "volume", + "settings", + "fullscreen", + ], + volume: 0.5, + muted: false, + loop: { + active: false, + }, + speed: { + selected: 1, + options: [0.5, 1, 1.5, 2], + }, + keyboard: { + focused: true, + global: false, + }, }} />
diff --git a/src/app/@preview.doc.tsx b/src/app/@preview.doc.tsx index 3b6380a..327370c 100644 --- a/src/app/@preview.doc.tsx +++ b/src/app/@preview.doc.tsx @@ -1,6 +1,6 @@ "use client"; -import DocViewer, { DocViewerRenderers } from "@cyntler/react-doc-viewer"; +import DocViewer, { DocRenderer } from "@cyntler/react-doc-viewer"; import { useEffect, useState } from "react"; import { z } from "zod"; import { Schema_File } from "~/schema"; @@ -8,15 +8,49 @@ import { cn } from "~/utils"; import Icon from "~/components/Icon"; +import config from "~/config/gIndex.config"; + import { CreateDownloadToken } from "./actions"; +const GoogleDocsViewerRenderer: DocRenderer = ({ + mainState: { currentDocument }, +}) => { + if (!currentDocument || !currentDocument.uri) return null; + + const viewerUrl = new URL(`/gview`, "https://docs.google.com"); + viewerUrl.searchParams.set("url", currentDocument.uri); + viewerUrl.searchParams.set("embedded", "true"); + + return ( +