E-Kuerschner / useAudioPlayer

React hooks for controlling audio on the web
MIT License
328 stars 36 forks source link

isLoading boolean #116

Closed brianshano closed 1 year ago

brianshano commented 1 year ago

Problem

When streaming an internet radio station e.g. in the example /globalAudio/state and select "streaming internet radio", there is a slight delay while it loads the stream. There is no visual queue to show that the stream is loading.

Solution

If the useGlobalAudioPlayer had a boolean for isLoading, it would be delightful! I tried using the isReady boolean, but it doesn't represent stream loading as it's deemed ready before that.

Alternatives

At the moment I'm setting a useState based on the call to 'load' a station and unsetting once the onload method is true but that isn't easily available as a global method then.

Additional context

Loving the new useGlobalAudioPlayer 🎉

E-Kuerschner commented 1 year ago

@brianshano thanks for reporting this! This was something I noticed as well and meant to document. If you have any ideas let me know. I don't even think the base howler library was handing this well, but I will think about what we can do

E-Kuerschner commented 1 year ago

hey @brianshano have you experienced this issue in any other context outside the example application? If so, I'd love to see a sandbox so i can test against other use cases as well

E-Kuerschner commented 1 year ago

hey @brianshano v2.1.0 adds an isLoading boolean and also addresses some issues around streaming audio. Give it a shot to see if solves your issue! Closing for now

brianshano commented 1 year ago

Yes! That works wonderfully! It's now really simple to display when the radio stream is loading.

Also I noticed passing the initialVolume prop works perfectly now too.

Great work, thanks 🙌