SimformSolutionsPvtLtd / react-native-audio-waveform

React Native component to show audio waveform with ease in react native application ✨
MIT License
141 stars 22 forks source link

feat: ability to stop all extractors #119

Open dprevost-LMI opened 4 weeks ago

dprevost-LMI commented 4 weeks ago

In a scenario where we want to use the audio player to load several audio messages for different conversations and where navigation between conversations is required only to show one conversation at a time, we need an efficient way to load the audio message but also to cancel nearly everything if we switch to another conversation.

In the above scenario, when navigating away from all those audio players being played or having their waveform extracted, we need to stop them. Otherwise, opening more and more conversations in a short period will bust resources (promises, players, extractors).

This PR provides a new stopAllWaveFormExtractors, which, when called, stops all waveform extraction to free resources for the following conversation that will be loaded. Combined with stopAllPlayers, the new stopPlayersAndExtractors in the useAudioPlayer hook provides a way to stop everything around the audio players to ensure that no more resources are spent on the unmount screen.

The new Stop all players and extractos option:

Screenshot 2024-11-16 at 8 27 04 AM

Other:

dprevost-LMI commented 2 days ago

Waiting on https://github.com/SimformSolutionsPvtLtd/react-native-audio-waveform/pull/123 merge to fix the player button s issue when clicking stop all

dprevost-LMI commented 6 hours ago

Now waiting on https://github.com/SimformSolutionsPvtLtd/react-native-audio-waveform/pull/136 since some promise rejections are missing to thoroughly test the player after stopping everything!