/** * The music control in the header. * * A single button toggles it; the caret opens the track list. The button's * label distinguishes three states rather than two, because "on but waiting * for a click" is a real state the browser puts us in and a speaker icon that * claims to be playing when nothing is audible is the confusing part. */ import { ChevronDown, Music, Volume2, VolumeX } from 'lucide-react'; import { PLATFORM_TRACKS, usePlatformAudio } from '@/lib/audio'; import { Button, cn } from './ui'; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from './ui/dropdown-menu'; export function AudioControl({ className }: { className?: string }) { const audio = usePlatformAudio(); if (!audio) return null; const { enabled, playing, track, toggle, setTrack } = audio; const current = PLATFORM_TRACKS.find((entry) => entry.id === track); const label = !enabled ? 'Play platform music' : playing ? `Mute platform music (${current?.label})` : 'Music starts when you interact with the page'; return (