-
Notifications
You must be signed in to change notification settings - Fork 24
Description
The q5 has been a very important tool in my processes. While p5 was a first step, q5 seems to lead me towards a better understanding of the processes and the possibility of being less and less dependent on a specific library. Thank you!
I'm trying to use the q5 together with the p5 sound and I followed everything that was indicated in the README: I included and linked the q5.p5acl.js in the correct sequence:
<script src="https://cdn.jsdelivr.net/gh/LingDong-/q5xjs/q5.min.js"></script>
<script src="./q5.p5acl.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/addons/p5.sound.min.js"></script>
I was able to load the audio file using let mySound = addons.loadSound('soundfile.mp3')
, but I can't use the same principle as p5 to play the sound: mySound.play()
.
This is my entire code:
let q5 = new Q5()
let mySound = addons.loadSound("Damscray_DancingTiger.mp3");
q5.setup = () => {
q5.createCanvas(100, 100)
q5.background(0)
}
q5.canvas.addEventListener('click', () => {
console.log('click')
mySound.play()
})
And this is the error on the console:
InvalidStateError: Failed to construct 'AudioWorkletNode': AudioWorkletNode cannot be created: AudioWorklet does not have a valid AudioWorkletGlobalScope. Load a script via audioWorklet.addModule() first. at undefined:2:97382
Am I making a mistake or is some additional code needed?