lhz516 / react-h5-audio-player

React audio player component with UI. It provides time indicator on both desktop and mobile devices.
https://codepen.io/lhz516/pen/dyGpmgP
MIT License
587 stars 91 forks source link

playing multiple audios #188

Closed imyosh closed 1 year ago

imyosh commented 1 year ago

Is there an option so that only one audio can be played at a time when rendering multiple audio elements ? so that when user click play to one the others set to pause state

lhz516 commented 1 year ago

You can save all the audio refs to one place, and when setting one of the audios to play, set all other audios to pause in the onPlay callback. The player UI will be automatically updated when you do audio.pause() method.

lhz516 commented 1 year ago

Closing it. Feel free to reopen if you need some followup discussion.