From 6bd32e110da95356c0ba188a0d850477b1347541 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Thu, 19 Feb 2026 23:00:47 -0800 Subject: fix: gesture requirement on chrome --- templates/index.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/templates/index.html b/templates/index.html index 49ea270..82adc42 100644 --- a/templates/index.html +++ b/templates/index.html @@ -396,9 +396,16 @@ updateNowPlaying(); setInterval(updateNowPlaying, 8000); - // resume audio context on gesture + document.addEventListener('click', function once(){ - try { if (window.AudioContext && window.AudioContext.prototype.resume) window.AudioContext.prototype.resume(); } catch(_) {} + try { + const actx = window.__ytRadioAudioContext; + if (actx && typeof actx.resume === 'function') { + actx.resume().catch(()=>{}); + } else { + audio.play().catch(()=>{}); + } + } catch(_) {} document.removeEventListener('click', once); }); @@ -407,6 +414,8 @@ const AudioCtx = window.AudioContext || window.webkitAudioContext; if (!AudioCtx) { canvas.style.display='none'; return; } const actx = new AudioCtx(); + // expose the AudioContext instance so the gesture handler can resume it + try { window.__ytRadioAudioContext = actx; } catch(e) {} let src; try { src = actx.createMediaElementSource(audio); } catch(e) { canvas.style.display='none'; return; } -- cgit v1.2.3