diff --git a/client/src/pages/VideoPage.tsx b/client/src/pages/VideoPage.tsx index 34cb325..916679f 100644 --- a/client/src/pages/VideoPage.tsx +++ b/client/src/pages/VideoPage.tsx @@ -31,7 +31,7 @@ const formatDate = (date: Date | string): string => { }); }; import { Button } from "@/components/ui/button"; -import { Share2, X, Edit3, Menu, Search } from "lucide-react"; +import { Share2, X, Edit3, Menu, Search, ChevronLeft, ChevronRight } from "lucide-react"; import { apiRequest } from "@/lib/queryClient"; import { FacebookShareButton, @@ -69,6 +69,30 @@ export default function VideoPage() { }); const recommendedVideos = recommendedResponse?.videos?.filter(v => v.id !== videoId) || []; + const allVideos = recommendedResponse?.videos || []; + + // Navigation functions + const getCurrentVideoIndex = () => { + if (!currentVideo || !allVideos.length) return -1; + return allVideos.findIndex((v) => v.id === currentVideo.id); + }; + + const navigateToVideo = (direction: 'next' | 'prev') => { + const currentIndex = getCurrentVideoIndex(); + if (currentIndex === -1) return; + + let newIndex; + if (direction === 'next') { + newIndex = currentIndex + 1 >= allVideos.length ? 0 : currentIndex + 1; + } else { + newIndex = currentIndex - 1 < 0 ? allVideos.length - 1 : currentIndex - 1; + } + + const newVideo = allVideos[newIndex]; + if (newVideo) { + window.location.href = `/video/${newVideo.id}`; + } + }; // Update page meta tags for social sharing @@ -297,6 +321,27 @@ export default function VideoPage() {
{/* Video player */}
+ {/* Navigation arrows */} + {allVideos.length > 1 && ( + <> + + + + )} {currentVideo.videoUrlIframe ? (