import { useEffect, useRef } from "react"; import { Link } from "react-router-dom"; import { ChevronDown, ChevronUp, Pencil } from "lucide-react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "@/components/ui/dialog"; import { Button } from "@/components/ui/button"; import { getVideoStreamUrl } from "@/lib/api"; import { formatBytes } from "@/lib/format"; import type { DiscoveryVideo } from "@/types"; interface VideoPlayerDialogProps { open: boolean; onOpenChange: (open: boolean) => void; video: DiscoveryVideo | null; onPrevious?: () => void; onNext?: () => void; hasPrevious?: boolean; hasNext?: boolean; onEdit?: (video: DiscoveryVideo) => void; } export function VideoPlayerDialog({ open, onOpenChange, video, onPrevious, onNext, hasPrevious, hasNext, onEdit, }: VideoPlayerDialogProps) { const videoRef = useRef(null); // Autoplay when the dialog opens or the video changes. The play() call may // be blocked if the browser considers the gesture consumed — the user can // always press play manually. useEffect(() => { if (open && video) { videoRef.current?.play().catch(() => {}); } }, [open, video]); // Arrow-key navigation. ↑/↓ always switch videos (when available) and are // captured in the CAPTURE phase with preventDefault, so they never reach // the