import { appStore, safeCall } from '../lib/app'; import { useStore } from '../lib/store'; import { Bar } from './Bar'; import { coverStyle, fmtMs } from '../lib/format'; import { PauseIcon, PlayIcon, SkipNextIcon } from './icons'; import { t } from '../i18n'; async function togglePlay() { const st = appStore.get().status || {}; if (st.isPlaying && !st.isPaused) await safeCall('Pause'); else await safeCall('Resume'); } // Mini player mirrors the current track on views other than Now Playing. export function MiniPlayer() { const s = useStore(appStore); if (s.view === 'dashboard' || !s.current) return null; const playing = !!(s.status && s.status.isPlaying && !s.status.isPaused); const canForceSkip = !!( s.identity && (s.identity.isAdmin || s.identity.isDj) ); const durationMs = s.durationMs || s.current.duration || 0; const pct = durationMs > 0 ? Math.min(100, (s.positionMs / durationMs) * 100) : 0; return (
{s.current.title}
{s.current.artist || ''}
{canForceSkip && ( )} durationMs ? fmtMs(Math.round(f * durationMs)) : '' } onDragStart={() => durationMs > 0} onCommit={(f) => safeCall('Seek', { position: Math.round(f * durationMs), }) } />
); }