import { useRef } from 'react' import { Play, Pause, Volume2, VolumeX, SkipBack, SkipForward } from 'lucide-react' import { usePlayerStore } from '@/stores/player' import { formatDuration } from '@/lib/utils' import { Avatar } from '@/components/ui/Avatar' export function PlayerBar() { const { current, isPlaying, isExternal, progress, duration, volume, toggle, seek, setVolume } = usePlayerStore() const seekRef = useRef(null) if (!current) return null const pct = duration ? (progress / duration) * 100 : 0 function handleSeek(e: React.MouseEvent) { if (!seekRef.current || isExternal) return const rect = seekRef.current.getBoundingClientRect() const ratio = Math.max(0, Math.min(1, (e.clientX - rect.left) / rect.width)) seek(ratio * duration) } return (
{/* Seek bar — full width, always visible */}
{!isExternal && (
)}
{/* Cover + info */}
{current.cover_url ? ( ) : ( )} {isPlaying && (
)}

{current.title}

{current.creator?.username}

{/* Controls */}
{!isExternal && ( )} {!isExternal && ( )}
{/* Time + Volume */}
{!isExternal ? `${formatDuration(progress)} / ${formatDuration(duration)}` : duration > 0 ? formatDuration(duration) : ''} setVolume(parseFloat(e.target.value))} className="w-20 accent-white [&::-webkit-slider-thumb]:!bg-white [&::-webkit-slider-thumb]:!shadow-none" />
) }