From c05b38e27a3beaac8f3abb3705953839778df2d2 Mon Sep 17 00:00:00 2001 From: codey Date: Sat, 19 Jul 2025 08:58:36 -0400 Subject: [PATCH] bugfix: borked station switching w/ prior revision ++ remove iOS tap to allow audio type overlay, not needed --- src/components/AudioPlayer.jsx | 46 ++++++++++------------------------ 1 file changed, 13 insertions(+), 33 deletions(-) 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 }]) => (