joshwcomeau / redux-sounds

Middleware for playing audio / sound effects using Howler.js
MIT License
131 stars 17 forks source link

Question: How can I load sounds lazily? #35

Closed wahidshafique closed 2 years ago

wahidshafique commented 3 years ago

I want to not have to preload sounds, but rather stream them in/load as the user wishes. Is there any quick way to accomplish that?

GeKorm commented 3 years ago

Hi, sorry I didn't get a notification. You can add sounds via redux actions as explained here https://github.com/joshwcomeau/redux-sounds#adding-more-sounds-via-actions but you may have to create an empty or dummy initial soundsData object to initialize the middleware.

wahidshafique commented 2 years ago

@GeKorm So I tried that using redux toolkit and it works, except onend it fails and gives an error

TypeError
Cannot read properties of undefined (reading '1002')
Howl.onend
https://1mxvw.csb.app/node_modules/redux-sounds/lib/howler_integration.js:2473:33
Howl.eval
https://1mxvw.csb.app/node_modules/howler/dist/howler.js:1886:16

reproduced here: https://codesandbox.io/s/redux-sounds-dynamic-add-bug-1mxvw?file=/src/features/counter/counterSlice.js Just load and then turn on the sound

GeKorm commented 2 years ago

Thanks for the repro @wahidshafique! Looking into it

wahidshafique commented 2 years ago

@GeKorm Hey thank you so much for the prompt fix, is it possible to roll a release for this, for some reason I cannot get it to work by just pointing to this github repo directly

GeKorm commented 2 years ago

3.1.1 published! I was just taking my time testing it 😄 Please let me know if you encounter any more problems with this, and thanks again for reporting it.

wahidshafique commented 2 years ago

@GeKorm You unblocked a very crucial part of our release train haha, thanks again man