-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from MEITREX/docproc-ai
Docproc ai
- Loading branch information
Showing
70 changed files
with
4,203 additions
and
2,350 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{ | ||
"extends": ["next/core-web-vitals", "prettier"] | ||
"extends": ["next/core-web-vitals", "prettier"], | ||
"rules": { | ||
"@next/next/no-img-element": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
app/courses/[courseId]/media/[mediaId]/ContentMediaDisplay.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
"use client"; | ||
import { ContentMediaDisplayFragment$key } from "@/__generated__/ContentMediaDisplayFragment.graphql"; | ||
import { ContentMediaDisplayVideoFragment$key } from "@/__generated__/ContentMediaDisplayVideoFragment.graphql"; | ||
import { PdfViewer } from "@/components/PdfViewer"; | ||
import { MediaPlayer, MediaProvider } from "@vidstack/react"; | ||
import { | ||
defaultLayoutIcons, | ||
DefaultVideoLayout, | ||
} from "@vidstack/react/player/layouts/default"; | ||
import "@vidstack/react/player/styles/default/layouts/video.css"; | ||
import "@vidstack/react/player/styles/default/theme.css"; | ||
import { useFragment } from "react-relay"; | ||
import { graphql } from "relay-runtime"; | ||
|
||
export function ContentMediaDisplay({ | ||
_record, | ||
onProgressChange, | ||
}: { | ||
_record: ContentMediaDisplayFragment$key; | ||
onProgressChange: (fraction: number) => void; | ||
}) { | ||
const mediaRecord = useFragment( | ||
graphql` | ||
fragment ContentMediaDisplayFragment on MediaRecord { | ||
type | ||
name | ||
standardizedDownloadUrl | ||
downloadUrl | ||
...ContentMediaDisplayVideoFragment | ||
} | ||
`, | ||
_record | ||
); | ||
|
||
switch (mediaRecord.type) { | ||
case "VIDEO": | ||
return <VideoPlayer _video={mediaRecord} />; | ||
case "PRESENTATION": | ||
case "DOCUMENT": | ||
return ( | ||
<PdfViewer | ||
onProgressChange={onProgressChange} | ||
url={mediaRecord.standardizedDownloadUrl ?? mediaRecord.downloadUrl} | ||
/> | ||
); | ||
case "IMAGE": | ||
// eslint-disable-next-line @next/next/no-img-element | ||
return ( | ||
<img | ||
alt={mediaRecord.name} | ||
src={mediaRecord.standardizedDownloadUrl ?? mediaRecord.downloadUrl} | ||
className="max-h-md flex justify-center mx-auto" | ||
></img> | ||
); | ||
default: | ||
return <>Unsupported media type</>; | ||
} | ||
} | ||
|
||
export function VideoPlayer({ | ||
_video, | ||
}: { | ||
_video: ContentMediaDisplayVideoFragment$key; | ||
}) { | ||
const mediaRecord = useFragment( | ||
graphql` | ||
fragment ContentMediaDisplayVideoFragment on MediaRecord { | ||
type | ||
name | ||
standardizedDownloadUrl | ||
downloadUrl | ||
segments { | ||
id | ||
... on VideoRecordSegment { | ||
startTime | ||
transcript | ||
thumbnail | ||
title | ||
} | ||
} | ||
} | ||
`, | ||
_video | ||
); | ||
|
||
return ( | ||
<MediaPlayer | ||
src={mediaRecord.standardizedDownloadUrl ?? mediaRecord.downloadUrl} | ||
> | ||
<MediaProvider /> | ||
<DefaultVideoLayout icons={defaultLayoutIcons} /> | ||
</MediaPlayer> | ||
); | ||
} |
Oops, something went wrong.