bugfix: borked station switching w/ prior revision ++ remove iOS tap to allow audio type overlay, not needed

This commit is contained in:
2025-07-19 08:58:36 -04:00
parent f8bf23dd4f
commit c05b38e27a

View File

@@ -36,7 +36,6 @@ export function Player() {
const [coverArt, setCoverArt] = useState("/images/radio_art_default.jpg"); const [coverArt, setCoverArt] = useState("/images/radio_art_default.jpg");
const [elapsed, setElapsed] = useState(0); const [elapsed, setElapsed] = useState(0);
const [duration, setDuration] = useState(0); const [duration, setDuration] = useState(0);
const [userHasInteracted, setUserHasInteracted] = useState(false);
const soundRef = useRef(null); const soundRef = useRef(null);
const uuidRef = useRef(null); const uuidRef = useRef(null);
@@ -84,7 +83,6 @@ export function Player() {
}; };
const togglePlayback = () => { const togglePlayback = () => {
if (isIOS && !userHasInteracted) return; // block only on iOS until interaction
if (isPlaying) { if (isPlaying) {
soundRef.current?.pause(); soundRef.current?.pause();
setIsPlaying(false); setIsPlaying(false);
@@ -98,21 +96,22 @@ const togglePlayback = () => {
} }
}; };
useEffect(() => { useEffect(() => {
if (!userHasInteracted) return;
if (isPlaying) {
playStream();
} else {
if (soundRef.current) { if (soundRef.current) {
soundRef.current.stop(); soundRef.current.stop();
soundRef.current.unload(); soundRef.current.unload();
soundRef.current = null; soundRef.current = null;
} }
if (isPlaying) {
playStream();
} }
}, [activeStation]); }, [activeStation]);
useEffect(() => { useEffect(() => {
clearGlobalMetadataInterval(); clearGlobalMetadataInterval();
currentStationForInterval = activeStation; currentStationForInterval = activeStation;
@@ -170,25 +169,6 @@ const togglePlayback = () => {
return ( return (
<> <>
{/* Unlock overlay */}
{!userHasInteracted && isIOS && (
<div
className="fixed inset-0 z-50 bg-black bg-opacity-80 flex items-center justify-center text-white text-xl cursor-pointer"
onClick={() => {
setUserHasInteracted(true);
if (Howler.ctx?.state === "suspended") {
Howler.ctx.resume();
}
playStream(); // <-- Immediate play within same gesture
}}
>
Tap to Start Audio
</div>
)}
<div className="station-tabs flex gap-2 justify-center mb-4 flex-wrap z-10 relative"> <div className="station-tabs flex gap-2 justify-center mb-4 flex-wrap z-10 relative">
{Object.entries(STATIONS).map(([key, { label }]) => ( {Object.entries(STATIONS).map(([key, { label }]) => (
<button <button