forked from code100x/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
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 code100x#1573 from code100x/feat-appx-video
feat: embed appx video player
- Loading branch information
Showing
11 changed files
with
183 additions
and
36 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
prisma/migrations/20241121062529_add_appx_fields/migration.sql
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,5 @@ | ||
-- AlterTable | ||
ALTER TABLE "User" ADD COLUMN "appxAuthToken" TEXT; | ||
|
||
-- AlterTable | ||
ALTER TABLE "VideoMetadata" ADD COLUMN "appxVideoId" TEXT; |
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
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,41 @@ | ||
'use client'; | ||
import { GetAppxVideoPlayerUrl } from '@/actions/user'; | ||
import { signOut } from 'next-auth/react'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { toast } from 'sonner'; | ||
|
||
export const AppxVideoPlayer = ({ | ||
courseId, | ||
videoId, | ||
}: { | ||
courseId: string; | ||
videoId: string; | ||
}) => { | ||
const [url, setUrl] = useState(''); | ||
const doneRef = useRef(false); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
if (doneRef.current) return; | ||
doneRef.current = true; | ||
try { | ||
const videoUrl = await GetAppxVideoPlayerUrl(courseId, videoId); | ||
setUrl(videoUrl); | ||
} catch { | ||
toast.info('This is a new type of video player', { | ||
description: 'Please relogin to continue', | ||
action: { | ||
label: 'Relogin', | ||
onClick: () => signOut(), | ||
}, | ||
}); | ||
} | ||
})(); | ||
}, []); | ||
|
||
if (!url.length) { | ||
return <p>Loading...</p>; | ||
} | ||
|
||
return <iframe src={url} className="h-[80vh] w-[80vw] rounded-lg"></iframe>; | ||
}; |
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
Oops, something went wrong.