Resume AudioContext on visibilitychange to fix SFX loss after backgrounding app

This commit is contained in:
Justin Oros
2026-05-20 20:32:14 -07:00
parent 18809b6b86
commit c1d6eab38e
+5
View File
@@ -126,6 +126,11 @@ const SFX = (() => {
}
document.addEventListener('touchstart', unlock, { once: true, passive: true });
document.addEventListener('pointerdown', unlock, { once: true, passive: true });
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible' && ctx && ctx.state === 'suspended') {
ctx.resume();
}
});
/* Core: play a tone with envelope */
function tone(freq, type, vol, attack, sustain, release, when) {