Skip to content

Commit

Permalink
fix: video not loading issue (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
devsargam authored Dec 2, 2024
1 parent dbc976e commit 9bbb44c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/components/VideoPlayer2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
subtitles,
onVideoEnd,
appxVideoId,
appxCourseId
appxCourseId,
}) => {
const videoRef = useRef<HTMLDivElement>(null);
const playerRef = useRef<Player | null>(null);
Expand Down Expand Up @@ -484,7 +484,7 @@ export const VideoPlayer: FunctionComponent<VideoPlayerProps> = ({
return (
<div
data-vjs-player
style={{ maxWidth: '850px', margin: '0 auto', width: '100%' }}
style={{ maxWidth: '1350px', margin: '0 auto', width: '100%' }}
>
<div ref={videoRef} style={{ width: '100%', height: 'auto' }} />
</div>
Expand Down
11 changes: 5 additions & 6 deletions src/components/admin/ContentRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,11 @@ export const ContentRenderer = async ({
};
}) => {
const metadata = await getMetadata(content.id);
const appxCourseId = await getAppxCourseId(content.courseId);
if (!appxCourseId) {
return <div>Loading...</div>;
}
//@ts-ignore
const appxVideoId: string = metadata?.appxVideoJSON[appxCourseId];
const result = await getAppxCourseId(content.courseId);
const appxCourseId = typeof result !== 'string' ? '' : result;

// @ts-ignore
const appxVideoId: string = metadata?.appxVideoJSON?.[appxCourseId] ?? '';

return (
<div>
Expand Down
17 changes: 9 additions & 8 deletions src/utiles/appx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,21 +231,22 @@ export async function getAppxCourseId(courseId: string) {
course: true,
},
orderBy: {
courseId: 'asc'
}
courseId: 'asc',
},
});

const CMS_APPX_COURSE_MAP: Record<string, string[]> = {
13: ["8", "10"],
14: ["8", "9", "11"],
15: ["8", "9", "12"]
13: ['8', '10'],
14: ['8', '9', '11'],
15: ['8', '9', '12'],
};

let appxCourseId: string | null = null;
parentCourses.forEach((pc => {
if (CMS_APPX_COURSE_MAP[courseId].includes(pc.courseId.toString())) {
if (!CMS_APPX_COURSE_MAP[courseId]) return '';
parentCourses.forEach((pc) => {
if (CMS_APPX_COURSE_MAP[courseId]?.includes(pc.courseId.toString())) {
appxCourseId = pc.course.appxCourseId;
}
}));
});
return appxCourseId;
}

0 comments on commit 9bbb44c

Please sign in to comment.