'use client' import { useEffect, useRef, useState } from 'react' import TagSelector from '@/components/tags/TagSelector' import { useUserSettings } from '@/hooks/useUserSettings' interface Props { url: string name: string onClose: () => void onPrev?: () => void onNext?: () => void itemKey?: string onTagsChanged?: () => void onAiTag?: () => Promise context?: 'mixed' | 'movies' | 'tv' } export default function VideoPlayerModal({ url, name, onClose, onPrev, onNext, itemKey, onTagsChanged, onAiTag, context = 'mixed' }: Props) { const settings = useUserSettings() const autoPlay = context === 'mixed' ? settings.mixedAutoplay : context === 'movies' ? settings.moviesAutoplay : settings.tvAutoplay const loop = context === 'mixed' ? settings.mixedLoop : context === 'movies' ? settings.moviesLoop : settings.tvLoop const muted = context === 'mixed' ? settings.mixedMuted : context === 'movies' ? settings.moviesMuted : settings.tvMuted const overlayRef = useRef(null) const [showTags, setShowTags] = useState(false) const [aiTagging, setAiTagging] = useState(false) const [aiTagError, setAiTagError] = useState(null) const [tagRefreshKey, setTagRefreshKey] = useState(0) useEffect(() => { const handleKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose() if (e.key === 'ArrowLeft') onPrev?.() if (e.key === 'ArrowRight') onNext?.() } document.addEventListener('keydown', handleKey) document.body.style.overflow = 'hidden' return () => { document.removeEventListener('keydown', handleKey) document.body.style.overflow = '' } }, [onClose, onPrev, onNext]) const handleOverlayClick = (e: React.MouseEvent) => { if (e.target === overlayRef.current) onClose() } return (
{/* Toolbar */}
{name}
{itemKey && ( )} {onAiTag && ( )}
{showTags ? (
{/* Video */}
{/* Tag panel */}
e.stopPropagation()} >

Tags

) : (
)}
) }