// Wander — Active tour player with real audio support function PlayerScreen({ tourId, onBack, onComplete, dense }) { const { TOURS, STOPS } = window.WANDER_DATA; const tour = TOURS.find(t => t.id===tourId) || TOURS[0]; const [playing, setPlaying] = React.useState(false); const [stopIdx, setStopIdx] = React.useState(2); const stop = STOPS[stopIdx]; const [progress, setProgress] = React.useState(0.34); const [tab, setTab] = React.useState('story'); const audioRef = React.useRef(null); // Sync simulated progress when no real audio React.useEffect(() => { if (tour.audio_url) return; // real audio handles progress if (!playing) return; const id = setInterval(() => setProgress(p => p>=1 ? 0 : Math.min(1, p+0.004)), 100); return () => clearInterval(id); }, [playing, tour.audio_url]); // Sync real audio React.useEffect(() => { const el = audioRef.current; if (!el) return; if (playing) el.play().catch(()=>{}); else el.pause(); }, [playing]); const handleAudioTimeUpdate = (e) => { const el = e.target; if (el.duration) setProgress(el.currentTime / el.duration); }; return (
{/* Hidden real audio element */} {tour.audio_url && (