import { Captions, ExternalLink, Pause, Play, Radio, SkipBack, SkipForward, Volume2 } from "lucide-react"; import { Button } from "./Button"; import { Slider } from "./Slider"; import styles from "./SpotifyPlayerBar.module.css"; type SpotifyPlayerBarProps = { className?: string; connected?: boolean; ready?: boolean; trackTitle?: string; artist?: string; album?: string; imageUrl?: string; externalUrl?: string; isPlaying?: boolean; positionMs?: number; durationMs?: number; volume?: number; error?: string; connectHref?: string; onTogglePlay?: () => void; onPrevious?: () => void; onNext?: () => void; onSeek?: (positionMs: number) => void; onVolume?: (volume: number) => void; lyricsOpen?: boolean; onToggleLyrics?: () => void; }; function formatTime(ms: number) { if (!Number.isFinite(ms) || ms <= 0) return "0:00"; const total = Math.floor(ms / 1000); const minutes = Math.floor(total / 60); return `${minutes}:${String(total % 60).padStart(2, "0")}`; } export function SpotifyPlayerBar({ className, connected = false, ready = false, trackTitle, artist, album = "Aurora SpotiRip", imageUrl, externalUrl, isPlaying = false, positionMs = 0, durationMs = 0, volume = 0.7, error, connectHref = "/_api/spotify-auth", onTogglePlay, onPrevious, onNext, onSeek, onVolume, lyricsOpen = false, onToggleLyrics, }: SpotifyPlayerBarProps) { const usable = connected && ready; const title = trackTitle || (connected ? "Nothing playing" : "Spotify playback"); const subtitle = error || artist || (!connected ? "Connect your account to activate playback" : ready ? "Press play on any song" : "Starting Spotify playback…"); return (
{imageUrl ? : }
{title} {subtitle}
{formatTime(positionMs)} onSeek?.(value[0] || 0)} /> {formatTime(durationMs)}
{album}
{connected && externalUrl ? ( Spotify ) : null} {connected ? ( <> onVolume?.(value[0] ?? volume)} /> ) : ( )}
); }