'use client'; import { useRef, useState } from 'react'; import { CircleIcon, PlayIcon } from 'lucide-react'; import clsx from 'clsx'; export const VideoPlayer = ({ autoPlay = true, controls = true, muted = true, maxWidth = '700px', poster, src, width, height, loop, preload = 'metadata', variant = 'primary', className, }: { autoPlay?: boolean; controls?: boolean; muted?: boolean; maxWidth?: string; poster?: string; src: string; width?: string; height?: string; loop?: boolean; preload?: 'none' | 'metadata' | 'auto'; variant?: 'primary' | 'secondary'; className?: string; }) => { const videoRef = useRef(null); const [isPlaying, setIsPlaying] = useState(autoPlay); const togglePlay = () => { if (!videoRef.current) { return; } if (!isPlaying) { setIsPlaying(true); videoRef.current.play(); const shouldLoop = typeof loop === 'boolean' ? loop : true; if (shouldLoop) { videoRef.current.setAttribute('loop', ''); } } }; return (
{!isPlaying ? ( ) : null}
); };