Resume AudioContext on visibilitychange to fix SFX loss after backgrounding app
This commit is contained in:
1 parent
18809b6b86
commit
c1d6eab38e
1 file changed
+5
@@ -126,6 +126,11 @@ const SFX = (() => {
|
|||||||
}
|
}
|
||||||
document.addEventListener('touchstart', unlock, { once: true, passive: true });
|
document.addEventListener('touchstart', unlock, { once: true, passive: true });
|
||||||
document.addEventListener('pointerdown', 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 */
|
/* Core: play a tone with envelope */
|
||||||
function tone(freq, type, vol, attack, sustain, release, when) {
|
function tone(freq, type, vol, attack, sustain, release, when) {
|
||||||
|
|||||||
Reference in new issue
Block a user