"use client"; import { AnimatePresence, motion, useInView } from "framer-motion"; import { Play } from "lucide-react"; import Image from "next/image"; import { useEffect, useRef, useState } from "react"; import { cn } from "~/lib/utils"; interface VideoPlayerProps { coverImage: string; videoSrc: string; title?: string; aspectRatio?: "square" | "video" | "vertical"; className?: string; } export function VideoPlayer({ coverImage, videoSrc, title, aspectRatio = "video", className, }: VideoPlayerProps) { const [isPlaying, setIsPlaying] = useState(false); const videoRef = useRef(null); const inView = useInView(videoRef); useEffect(() => { if (!inView) { setIsPlaying(false); } }, [inView]); const aspectRatioClasses = { square: "aspect-square", vertical: "aspect-[9/16]", video: "aspect-video", }; return (
{!isPlaying ? ( setIsPlaying(true)} transition={{ duration: 0.3 }} > {title
{title && (

{title}

)}
) : ( )}
); }