diff options
| author | Pinapelz <yukais@pinapelz.com> | 2026-02-19 23:00:47 -0800 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2026-02-19 23:00:47 -0800 |
| commit | 6bd32e110da95356c0ba188a0d850477b1347541 (patch) | |
| tree | aba32950983ab5367f6077020902a178d74f2d8b | |
| parent | 4ffdc887b6ff4393aeab0bb7a6fade8c44c4673a (diff) | |
fix: gesture requirement on chrome
| -rw-r--r-- | templates/index.html | 13 |
1 files 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; } |
