E-Kuerschner / useAudioPlayer

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

starting with empty src loads infinitely #110

Closed braco closed 1 year ago

braco commented 1 year ago

One might want to initialize the player without a src to use load() later, but

useAudioPlayer({ src: null })

seems to start with an infinite load. Is this expected behavior?

ZimNovich commented 1 year ago

seems to start with an infinite load. Is this expected behavior?

Yes, it is the default behavior:

export const initialState: AudioPlayerState = {
    loading: true,
    playing: false,
    stopped: true,
    ended: false,
    error: null,
    duration: 0,
    ready: false
}

They initialize the state with loading: true.

E-Kuerschner commented 1 year ago

hey @braco the behavior you are interested in is the default for version 2 which is currently available for testing on its alpha version. Please take a look at this version and provide any feedback if you'd like!

For now, on any 1.x.x version you must have the src ready at the time the hook is initialized.