Files
AetherForge/server/web/src/components/GlobalMusicPlayer.tsx
AetherForge a32860b0d9
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
feat: alive UI wave, galaxy presence, spread and fleet enhancements
Dashboard ambient layer, comrade presence, Mission Deck and War Room, Emberwake supply chain, spread/docs publishing, fleet policy and modules API, CI docker mining, and refreshed USB pack.
2026-06-04 22:36:17 -07:00

60 lines
2.1 KiB
TypeScript

import { useEffect } from 'react';
import { useLocation } from 'react-router-dom';
import { useAmbientMusic } from '../context/AmbientMusicContext';
import { resolvePageAmbientIntensity } from '../audio/ambientMusic';
import './GlobalMusicPlayer.css';
export default function GlobalMusicPlayer() {
const { enabled, playing, volume, setVolume, togglePlay, setPageIntensity, pageIntensity } = useAmbientMusic();
const location = useLocation();
const routeIntensity = resolvePageAmbientIntensity(location.pathname);
const isDim = routeIntensity < 0.5;
useEffect(() => {
setPageIntensity(routeIntensity);
}, [routeIntensity, setPageIntensity]);
return (
<div
className={`global-music-player${isDim ? ' global-music-player--ambient-dim' : ''}`}
data-sfx="off"
data-ambient-intensity={pageIntensity.toFixed(2)}
role="region"
aria-label="Background music controls"
>
<button
type="button"
className="global-music-player__play"
onClick={togglePlay}
aria-label={playing ? 'Pause background music' : 'Play background music'}
title={playing ? 'Pause music' : enabled ? 'Play music' : 'Enable & play music'}
>
{playing ? (
<svg viewBox="0 0 24 24" aria-hidden="true">
<rect x="6" y="5" width="4" height="14" rx="1" fill="currentColor" />
<rect x="14" y="5" width="4" height="14" rx="1" fill="currentColor" />
</svg>
) : (
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d="M8 5v14l11-7z" fill="currentColor" />
</svg>
)}
</button>
<label className="global-music-player__vol" title="Music volume">
<span className="sr-only">Music volume</span>
<input
type="range"
min={0}
max={100}
step={5}
value={Math.round(volume * 100)}
onChange={(e) => setVolume(parseInt(e.target.value, 10) / 100)}
aria-valuenow={Math.round(volume * 100)}
aria-valuemin={0}
aria-valuemax={100}
/>
</label>
</div>
);
}