aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2026-05-28 18:04:08 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2026-05-28 18:04:08 -0700
commitbbe912778407ee3434b68c959a72b834e1787ba9 (patch)
tree49a6649d193fb0d6c5186d0c3acc495face3a76b
parent61926dc28c427a87153b3a2a90544dbd3253325f (diff)
aero: autoplay music on startup with first-click fallback
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
-rwxr-xr-xindex.html25
1 files changed, 25 insertions, 0 deletions
diff --git a/index.html b/index.html
index 24490b4..940919e 100755
--- a/index.html
+++ b/index.html
@@ -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()