mirror of
https://github.com/eliasstepanik/strudel-docker.git
synced 2026-01-11 13:48:34 +00:00
init audio on first click to remove warning
This commit is contained in:
parent
00550ddab5
commit
b688b8921a
@ -176,14 +176,25 @@ function getWorklet(ac, processor, params) {
|
||||
return node;
|
||||
}
|
||||
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
loadWorklets();
|
||||
} catch (err) {
|
||||
console.warn('could not load AudioWorklet effects coarse, crush and shape', err);
|
||||
// this function should be called on first user interaction (to avoid console warning)
|
||||
export function initAudio() {
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
getAudioContext().resume();
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
function gainNode(value) {
|
||||
const node = getAudioContext().createGain();
|
||||
node.gain.value = value;
|
||||
|
||||
@ -18,7 +18,9 @@ import { controls, evalScope, logger } from '@strudel.cycles/core';
|
||||
import { createClient } from '@supabase/supabase-js';
|
||||
import { nanoid } from 'nanoid';
|
||||
import { useStrudel } from '@strudel.cycles/react';
|
||||
import { webaudioOutput } from '@strudel.cycles/webaudio';
|
||||
import { webaudioOutput, initAudioOnFirstClick } from '@strudel.cycles/webaudio';
|
||||
|
||||
initAudioOnFirstClick();
|
||||
|
||||
// Create a single supabase client for interacting with your database
|
||||
const supabase = createClient(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user