init audio on first click to remove warning
This commit is contained in:
parent
00550ddab5
commit
b688b8921a
2 changed files with 19 additions and 6 deletions
|
|
@ -176,12 +176,23 @@ function getWorklet(ac, processor, params) {
|
||||||
return node;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof window !== 'undefined') {
|
// this function should be called on first user interaction (to avoid console warning)
|
||||||
|
export function initAudio() {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
try {
|
try {
|
||||||
|
getAudioContext().resume();
|
||||||
loadWorklets();
|
loadWorklets();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.warn('could not load AudioWorklet effects coarse, crush and shape', 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) {
|
function gainNode(value) {
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,9 @@ import { controls, evalScope, logger } from '@strudel.cycles/core';
|
||||||
import { createClient } from '@supabase/supabase-js';
|
import { createClient } from '@supabase/supabase-js';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import { useStrudel } from '@strudel.cycles/react';
|
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
|
// Create a single supabase client for interacting with your database
|
||||||
const supabase = createClient(
|
const supabase = createClient(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue