diff --git a/.gitignore b/.gitignore index 5505499..3a25a46 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ dist/ build/ .vite/ *.tsbuildinfo +data/ server.exe .DS_Store .env diff --git a/apps/web/src/components/player-bar.tsx b/apps/web/src/components/player-bar.tsx index 54feb62..40ac6b7 100644 --- a/apps/web/src/components/player-bar.tsx +++ b/apps/web/src/components/player-bar.tsx @@ -1,16 +1,31 @@ +import { useEffect, useRef } from 'react' import { Pause, Play, SkipBack, SkipForward, Volume2 } from 'lucide-react' import { usePlayerStore } from '@/stores/player-store' +import { useSessionStore } from '@/stores/session-store' export function PlayerBar() { const currentTrack = usePlayerStore((state) => state.currentTrack) + const token = useSessionStore((state) => state.token) + const audioRef = useRef(null) + const apiBase = import.meta.env.VITE_API_BASE ?? 'http://localhost:4040' + + useEffect(() => { + if (!audioRef.current || !currentTrack || !token) { + return + } + + audioRef.current.src = `${apiBase}/api/stream/${currentTrack.id}?token=${token}` + void audioRef.current.play().catch(() => {}) + }, [apiBase, currentTrack, token]) return (
+