Audio restarts playing after pressing back button when using Expo Audio on iOS

#1

Hey,
I’m using the Expo example of an Audio player from here https://github.com/expo/playlist-example. Everything works great however when I press the back button to go back home in the App the audio stops (as it should) for a few seconds then starts again. I tried to unmountAsync() in the componenwillUnmount() function however I just get an error telling me I’m trying to smchange component state after its unmounted.
I’m trying to see if I’m using the library wrong, I’m using it as is right now with a minor addition in the componentWillUnmount() function.

#2

Hey @msarnaot,

Can you create a Snack demonstrating this behavior so I can try and replicate it on my end?

Cheers,

Adam

#3

Hey adamjnav,

I appreciate your quick reply. I created this snack https://snack.expo.io/@msarnaot/audioerror.

However, I wasn’t able to add the assets to the snack (this is my first time using it) not sure why I keep getting an error when adding the assets to the snack. However they can be found here https://github.com/expo/playlist-example/tree/master/assets. Apologies for the extra step.

To give you a general idea of the workflow here:

  1. User lands on home page, does some work and gets navigated to the audio player
  2. The audio player code is in the snack I included above.
  3. User clicks back button to navigate back to home
  4. Audio stops playing for a second or so, then restarts again from the beginning
#4

Hey @adamjnav were you able to replicate it on your end??

closed #5

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.