import { Play, Pause, SkipBack, SkipForward, Volume2, ListMusic, Shuffle, Repeat, Repeat1, MicVocal, ThumbsDown } from 'lucide-react'; import { Link } from '@tanstack/react-router'; import { usePlaybackStore } from '../store/usePlaybackStore'; import { useDislikeTrack } from '../hooks/useDislikeTrack'; import { Artwork } from './Artwork'; import { ArtistLinks } from './ArtistLinks'; import { formatDuration } from './TrackRow'; import { DevicePicker } from './DevicePicker'; import { usePlaybackSyncContext } from './PlaybackSyncProvider'; interface PlaybackBarProps { queueOpen: boolean; lyricsOpen: boolean; onToggleQueue: () => void; onToggleLyrics: () => void; } export function PlaybackBar({ queueOpen, lyricsOpen, onToggleQueue, onToggleLyrics }: PlaybackBarProps) { const { currentTrack, isPlaying, position, duration, volume, shuffle, repeat, play, pause, next, prev, setPosition, setVolume, toggleShuffle, cycleRepeat } = usePlaybackStore(); const dislikeTrack = useDislikeTrack(); const { hasRemoteOwner, sendCommand } = usePlaybackSyncContext(); // While another device holds the audio, the transport is a remote: the press // travels to that device instead of starting a second stream here. const remote = { play: () => (hasRemoteOwner ? void sendCommand({ type: 'play' }) : play()), pause: () => (hasRemoteOwner ? void sendCommand({ type: 'pause' }) : pause()), next: () => (hasRemoteOwner ? void sendCommand({ type: 'next' }) : next()), prev: () => (hasRemoteOwner ? void sendCommand({ type: 'prev' }) : prev()), seek: (seconds: number) => hasRemoteOwner ? void sendCommand({ type: 'seek', position: seconds }) : setPosition(seconds), }; const handleDislike = () => { if (!currentTrack) return; dislikeTrack(currentTrack.id); }; return (
{/* Track info */}
{currentTrack ? ( <> {currentTrack.album_id ? ( ) : (
)}
{currentTrack.album_id ? ( {currentTrack.title} ) : (
{currentTrack.title}
)}
) : (
{/* Reached only before anything has ever played in this browser — a returning tab restores its last track instead. */}
Pick a track to start
)}
{/* Controls + scrubber */}
{formatDuration(position)} remote.seek(Number(e.target.value))} disabled={!currentTrack || duration <= 0} className="flex-1 h-1 cursor-pointer" aria-label="Seek" /> {formatDuration(duration)}
{/* Volume + panel toggle */}
setVolume(Number(e.target.value))} className="hidden w-20 h-1 cursor-pointer sm:block" aria-label="Volume" />
); }