diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-28 18:04:08 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-28 18:04:08 -0700 |
| commit | bbe912778407ee3434b68c959a72b834e1787ba9 (patch) | |
| tree | 49a6649d193fb0d6c5186d0c3acc495face3a76b | |
| parent | 61926dc28c427a87153b3a2a90544dbd3253325f (diff) | |
aero: autoplay music on startup with first-click fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rwxr-xr-x | index.html | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -767,6 +767,31 @@ // swap track live when theme changes while music is playing window.addEventListener('themechange', applyMusicTheme); + // autoplay on load; fall back to first click if browser blocks it + (function() { + const track = MUSIC[Aero.getTheme()] || MUSIC.aero; + bgm.src = track.src; + bgm.load(); + bgm.play().then(() => { + musicOn = true; + mtBtn.textContent = '❚❚'; + mtLabel.textContent = track.label; + mtBtn.style.background = 'radial-gradient(circle at 30% 25%,white,oklch(75% 0.14 55) 60%,oklch(55% 0.15 35))'; + }).catch(() => { + document.addEventListener('click', () => { + const t = MUSIC[Aero.getTheme()] || MUSIC.aero; + bgm.src = t.src; + bgm.load(); + bgm.play().then(() => { + musicOn = true; + mtBtn.textContent = '❚❚'; + mtLabel.textContent = t.label; + mtBtn.style.background = 'radial-gradient(circle at 30% 25%,white,oklch(75% 0.14 55) 60%,oklch(55% 0.15 35))'; + }); + }, { once: true }); + }); + })(); + // counter document.getElementById('cc').innerHTML = Aero.counterHTML(0, 'visitors'); Aero.fetchVisitorCount() |
