Closed whitaiji closed 10 months ago
I have found a work around, looking around the net. I first tried importing with next/dynamic
const Wad = dynamic(() => import('web-audio-daw'), { ssr: false })
but would not import as a constructor, no luck there.
So after a few more searches, I managed to make it work this way, without importing Wad at the top
:
const MusicPlayer = () => {
const [wad, setWad] = useState()
useEffect(()=>{
const init = async () => {
const WadConstructor = (await import('web-audio-daw')).default;
const wads = {
saw: new WadConstructor({source : 'sawtooth'})
}
setWad(wads)
}
init()
},[])
const testFunction = () => {
console.log(wad)
wad.saw.play()
}
return (
<div>
<button onClick={testFunction}>test button music player</button>
</div>
)
}
export default MusicPlayer
Sound played, so far so good. But of course a bug fix would be much appreciated great work by the way, love it!
all the best
Mike
Hi! I have just installed your library, as soon as I import Wad from 'web-audio-daw'
I get a "ReferenceError: window is not defined" in node_modules/web-audio-daw/build/wad.js (10:4)
I am using NextJs v 12.1.0. Any idea what it could be?
thank you for your help
Mike