"use client" import { useState } from "react" import { Play, Pause, SkipBack, SkipForward, Shuffle, Repeat, Repeat1, Volume2, VolumeX, ListMusic, Download, } from "lucide-react" import { usePlayerStore } from "@/store/player-store" import { formatDuration } from "@/lib/utils" import { Slider } from "@/components/ui/slider" import { useAudioPlayer } from "@/hooks/use-audio-player" import { QueuePanel } from "./queue-panel" export const PlayerBar = () => { useAudioPlayer() const [isQueueOpen, setIsQueueOpen] = useState(false) const isPlaying = usePlayerStore((state) => state.isPlaying) const currentTrack = usePlayerStore((state) => state.currentTrack) const playbackPosition = usePlayerStore((state) => state.playbackPosition) const volume = usePlayerStore((state) => state.volume) const repeatMode = usePlayerStore((state) => state.repeatMode) const isShuffled = usePlayerStore((state) => state.isShuffled) const streamUrl = usePlayerStore((state) => state.streamUrl) const { playPause, nextTrack, prevTrack, seekTo, setVolume, toggleShuffle, cycleRepeatMode } = usePlayerStore( (state) => state.actions, ) const handleSeek = (value: number[]) => { seekTo(value[0]) } const handleVolumeChange = (value: number[]) => { setVolume(value[0]) } const handleDownload = () => { if (streamUrl && currentTrack) { const link = document.createElement("a") link.href = streamUrl link.download = `${currentTrack.artistName} - ${currentTrack.title}.flac` link.click() } } const RepeatIcon = repeatMode === "one" ? Repeat1 : Repeat return ( <>
{currentTrack ? ( <>
{currentTrack.title}
{currentTrack.title}
{currentTrack.artistName}
) : ( <>
No track playing
qstream
)}
{formatDuration(playbackPosition)} {currentTrack ? formatDuration(currentTrack.duration) : "0:00"}
{volume === 0 ? ( ) : ( )}
setIsQueueOpen(false)} /> ) }