How to cancel expo-av Audio while Loading

  1. SDK Version: 35.0.0
  2. Platforms: Android and iOS

I have used expo-av to implement an audio player with success. Now to improve user experience i need to be able to cancel an audio object that is still loading as below:

User’s perspective:
1 - While listening to track 4 skip to track 5
2 - while still loading track 5 skip to track 6


/* Here playbackObject is not null and is already loading track 5*/

const status = await playbackObject.getStatusAsync();
if(status.isLoaded == false){ //Still loading track 5
        await playbackObject.unloadAsync(); // throws error (Audio is not loaded)
        await playbackObject.loadAsync(source, initialStatus); //loads track 6

I end up with tracks 5 and 6 playing at the same time.

How can i cancel loading track 5 while status.isLoaded == false ?

Thank you

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