Replies: 2 comments
-
|
I've been trying to figure this out. I think the version difference is the main clue. Where does the 1.9.4 of p5js version come from? |
Beta Was this translation helpful? Give feedback.
-
|
Another thing I tried is downgrading p5 to 1.9.4. Same version is used in both places, but when the sketch is created loadSound does not exist on the prototype. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have used react-p5-wrapper for years in my nextjs website. I was able to import p5 sound into it with no issues. Recently, I decided to update some libraries and saw that react-p5-wrapper has been depricated and instead we should use @p5-wrapper/next. So, I swapped out libraries and most of my sketches work just fine. But all the ones that use p5 sound library fail. Basically loadSound function is not found on the p5 instance. I looked at dozen of websites and I tried all the different solution, but I just can't get it to work. Please help!
I am using next version 14.2.32, @p5-wrapper/next version 1.0.3 and @p5-wrapper/react version 4.4.2, p5 version 1.11.10. I did not want to upgrade to next 15 due to the router changes. I am hoping that does not matter.
Can someone help me with this? I am lost.
Update 1: I noticed that the window object has a property p5, it has a prototype and that has function loadSound. This function does not seem to appear on the p5 object itself even after loading p5, setting window.p5 to it and then loading sound library.
If I do call window.p5.prototype.loadSound I get errors once the sound is getting played. In Firefox I get this:
In Safari, from AudioWorkletNode:
In Brave (and I assume Chrome):
It is exact same library version as I used previously and the same as the one that gets included in the latest p5 version. So, I assume it has something to do with my React / Nextjs / p5 setup.
Update 2: Digging around a bit more I noticed that p5 that I load within useEffect has a version 1.11.10 and that does have loadSound on the prototype. The version on the instance is 1.9.4 and that does not have loadSound. Where does that version come from? When I run npm ls p5 it shows that I have version 1.11.10 installed and p5-wrapper/next also uses that version and it was deduped. I did a search for 1.9.4, and that is the minimum version that p5-wrapper/next requires, but it is not installed anywhere. I deleted .next and node_modules, still same issue.
Beta Was this translation helpful? Give feedback.
All reactions