diff --git a/src/components/AudioPlayer.jsx b/src/components/AudioPlayer.jsx index ba30e0c..01e5964 100644 --- a/src/components/AudioPlayer.jsx +++ b/src/components/AudioPlayer.jsx @@ -36,7 +36,6 @@ export function Player() { const [coverArt, setCoverArt] = useState("/images/radio_art_default.jpg"); const [elapsed, setElapsed] = useState(0); const [duration, setDuration] = useState(0); - const [userHasInteracted, setUserHasInteracted] = useState(false); const soundRef = useRef(null); const uuidRef = useRef(null); @@ -84,7 +83,6 @@ export function Player() { }; const togglePlayback = () => { - if (isIOS && !userHasInteracted) return; // block only on iOS until interaction if (isPlaying) { soundRef.current?.pause(); setIsPlaying(false); @@ -98,20 +96,21 @@ const togglePlayback = () => { } }; +useEffect(() => { + if (soundRef.current) { + soundRef.current.stop(); + soundRef.current.unload(); + soundRef.current = null; + } + + if (isPlaying) { + playStream(); + } + +}, [activeStation]); + - useEffect(() => { - if (!userHasInteracted) return; - if (isPlaying) { - playStream(); - } else { - if (soundRef.current) { - soundRef.current.stop(); - soundRef.current.unload(); - soundRef.current = null; - } - } - }, [activeStation]); useEffect(() => { clearGlobalMetadataInterval(); @@ -170,25 +169,6 @@ const togglePlayback = () => { return ( <> - {/* Unlock overlay */} - {!userHasInteracted && isIOS && ( -
{ - setUserHasInteracted(true); - - if (Howler.ctx?.state === "suspended") { - Howler.ctx.resume(); - } - - playStream(); // <-- Immediate play within same gesture - }} - - > - Tap to Start Audio -
- )} -
{Object.entries(STATIONS).map(([key, { label }]) => (