Expo Audio with React Native and Firebase

Please provide the following:

  1. SDK Version: 39
  2. Platforms(Android/iOS/web/all): Android/iOS

I am currently building my first app that loads audio files from firebase storage and loads them through expo audio in react native.

While the audio is loading, if the user navigates away from the page the audio will begin to play and there is no way to stop it.

Is there a way to cancel the loadAsync as a cleanUp function?

I cannot call stopAsync or unloadAsync as a cleanUp function since the audio has yet to be loaded.

I have also tried some methods involving redux where i trigger a boolean value on leaving the page that would stop the audio from playing but with no luck.

Thanks in advance for any help or guidance.

I decided to use Audio.setIsEnabledAsync(false) as a cleanUp function, but I feel this still isn’t the right way to go about this.

useEffect(() => {
Audio.setIsEnabledAsync(true);
return function cleanUp() {
Audio.setIsEnabledAsync(false)
}
}, )