Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add functionality to play next video automatically #1431

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/courses/[courseId]/[...moduleId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { QueryParams } from '@/actions/types';
import { CourseView } from '@/components/CourseView';
import { getCourse, getFullCourseContent } from '@/db/course';
import { getCourse, getFullCourseContent, getNextVideo } from '@/db/course';
import findContentById from '@/lib/find-content-by-id';

export default async function Course({
Expand All @@ -20,7 +20,7 @@ export default async function Course({
fullCourseContent,
rest.map((x) => parseInt(x, 10)),
);
const nextContent = null; //await getNextVideo(Number(rest[rest.length - 1]))
const nextContent = await getNextVideo(Number(rest[rest.length - 1]));

return (
<CourseView
Expand Down
18 changes: 9 additions & 9 deletions src/components/CourseView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ export const CourseView = ({
rest: string[];
course: any;
courseContent:
| {
folder: true;
value: ChildCourseContent[];
}
| {
folder: false;
value: ChildCourseContent;
}
| null;
| {
folder: true;
value: ChildCourseContent[];
}
| {
folder: false;
value: ChildCourseContent;
}
| null;
nextContent: any;
searchParams: QueryParams;
possiblePath: string;
Expand Down
4 changes: 3 additions & 1 deletion src/components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ export function Sidebar({
variants={sidebarVariants}
className="fixed right-0 top-0 z-[99999] flex h-screen w-full flex-col gap-4 overflow-y-auto rounded-r-lg border-l border-primary/10 bg-neutral-50 dark:bg-neutral-900 md:max-w-[30vw]"
>
<div className="sticky top-0 z-10 flex items-center justify-between border-b border-primary/10 bg-neutral-50 p-5 dark:bg-neutral-900"> <h4 className="text-xl font-bold tracking-tighter text-primary lg:text-2xl">
<div className="sticky top-0 z-10 flex items-center justify-between border-b border-primary/10 bg-neutral-50 p-5 dark:bg-neutral-900">
{' '}
<h4 className="text-xl font-bold tracking-tighter text-primary lg:text-2xl">
Course Content
</h4>
<Button
Expand Down
31 changes: 17 additions & 14 deletions src/components/admin/ContentRendererClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,17 @@ export const ContentRendererClient = ({
setShowChapters((prev) => !prev);
};

const triggerNextContent = () => {
const originalPath = window.location.pathname;
const parts = originalPath.split('/');
parts.pop();
if (nextContent) {
parts.push(nextContent.id.toString());
}
const newPath = parts.join('/');
router.push(newPath);
};

return (
<div className="flex w-full flex-col gap-2">
<div className="flex w-full flex-col">
Expand Down Expand Up @@ -98,7 +109,7 @@ export const ContentRendererClient = ({
responsive: true,
sources: [source],
}}
onVideoEnd={() => {}}
onVideoEnd={() => triggerNextContent()}
/>
<div className="flex flex-col gap-4 rounded-xl bg-primary/5 p-4">
<div className="flex w-full flex-col justify-between gap-2 md:flex-row">
Expand Down Expand Up @@ -140,19 +151,11 @@ export const ContentRendererClient = ({
)}
</div>
{nextContent ? (
<Button
size={'lg'}
onClick={() => {
const originalPath = window.location.pathname;
const parts = originalPath.split('/');
parts.pop();
parts.push(nextContent.id.toString());
const newPath = parts.join('/');
router.push(newPath);
}}
>
{nextContent.title}
</Button>
<div className="ml-auto mt-2">
<Button size={'lg'} onClick={() => triggerNextContent()}>
{nextContent.title}
</Button>
</div>
) : null}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/comment/CommentVoteForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,4 @@ const CommentVoteForm: React.FC<CommentVoteFormProps> = ({
);
};

export default CommentVoteForm;
export default CommentVoteForm;