Rajaniraiyn / svelte-sound

sound interactions made easy
https://rajaniraiyn.github.io/svelte-sound/
MIT License
39 stars 2 forks source link

HowlerJS loading issue on build #100

Open kimonmeier opened 3 weeks ago

kimonmeier commented 3 weeks ago

Dear Rajaniraiyn

Im currently using svelte-sound in my project Repo. While running the vite dev server everything works as intended without any errors. But as soon as im trying to build the project with the static or node adapter the whole thing falls apart. It looks like the howler core couldn't be correctly loaded. I created an empty project to test the behaviour. Empty Repo. Still the same issue. Do you have any idea what could be wrong?

Steps to reproduce:

Btw. Thanks for your awesome project <3

image image

Rajaniraiyn commented 3 weeks ago

Hi @kimonmeier,

Thank you for reaching out and for your support!

I've tested the repo to reproduce the issue you mentioned. It appears that the problem arises because you are attempting to play audio within onMount without any user interaction.

To enable autoplay behavior, specific conditions must be met. You can find these requirements detailed in the Autoplay Guide.

Below is the modified code that works by playing audio on user interaction (click):

Screenshot 2024-06-15 at 12 25 20 AM

If this helps resolve your issue, please close this thread. If you are still facing any problems, feel free to continue the discussion here or open a new issue.

kimonmeier commented 3 weeks ago

Thank you so much for answering so fast.

I changed my example in the Testing Repo so it meets the autoplay guide. Sadly, it still doesn't work. I want to further clarify that the problem only appears if i build the project with an adapter, the issue doesn't appear if I just start the dev server with npm run dev. For it to appear, I need to build it and then run it with npm run preview. I think it has something to-do with the dynamic import. I would appreciate it if you could take another look over it.

image

Rajaniraiyn commented 2 weeks ago

@kimonmeier Thanks for getting back. I got the bug and started working on it. its just double bundling of howlerjs. I'll update you with some temporary fix as well as update the library with fixes