E-Kuerschner / useAudioPlayer

React hooks for controlling audio on the web
MIT License
315 stars 35 forks source link

Move position state to Provider #39

Closed E-Kuerschner closed 3 years ago

E-Kuerschner commented 3 years ago

The useAudioPosition hook stores its own position state and encapsulates its own seek function. This doesn't allow a developer to use multiple instances of the hook and maintain synchronized stated when seek is invoked from one of them.

An example use case would be this: A developer has a seek bar component and a separate time component. When seek is invoked from within the seek bar component the position in both the seek bar and time components should be the same.

A separate React context for holding position state may be necessary so that consumers of the other player state (duration, isPlaying, etc.) do not rerender constantly as the position changes every second.

humbkr commented 3 years ago

I'll try to work on this today.

E-Kuerschner commented 3 years ago

@humbkr available in 1.0.1