mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 21:58:31 +00:00
can now await initAudio + initAudioOnFirstClick
This commit is contained in:
parent
1457eb9d19
commit
014ae2107e
@ -126,21 +126,24 @@ function getWorklet(ac, processor, params) {
|
||||
}
|
||||
|
||||
// this function should be called on first user interaction (to avoid console warning)
|
||||
export function initAudio() {
|
||||
export async function initAudio() {
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
getAudioContext().resume();
|
||||
loadWorklets();
|
||||
await getAudioContext().resume();
|
||||
await loadWorklets();
|
||||
} catch (err) {
|
||||
console.warn('could not load AudioWorklet effects coarse, crush and shape', err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function initAudioOnFirstClick() {
|
||||
document.addEventListener('click', function listener() {
|
||||
initAudio();
|
||||
document.removeEventListener('click', listener);
|
||||
export async function initAudioOnFirstClick() {
|
||||
return new Promise((resolve) => {
|
||||
document.addEventListener('click', async function listener() {
|
||||
await initAudio();
|
||||
resolve();
|
||||
document.removeEventListener('click', listener);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user