// Click-to-start gate. // // Browsers reject `audio.play()` without a user gesture. After a hard reload // we want to resume playback automatically when possible and fall back to a // "tap to start" modal otherwise. Inside the Electron shell autoplay is // permitted, so a one-time "Don't show again" pref suppresses the modal. // // Usage: // const ok = await tryAutoplay(audioEl); // best-effort attempt // if (!ok) { // await showStartModal({ stationName, onStart, onCancel }); // } const DISMISSED_KEY = 'oradio.autoplayDismissed'; function isElectron() { try { return !!(typeof window !== 'undefined' && window.oradioNative?.isElectron); } catch { return false; } } export function autoplayDismissed() { // Only honour the dismissal in Electron — plain browsers can't bypass // their autoplay policy regardless of any flag we set. if (!isElectron()) return false; try { return localStorage.getItem(DISMISSED_KEY) === '1'; } catch { return false; } } /** Try to start an