0

I'm very frustrated at this point. I've been reading the expo documentation and online answers as well but nothing is helping.

Honestly would pay money at this point for a solution...

my issue is that no matter what I try, I just can't seem to play the next audio clip after my current audio file has finished playing.

I know there is an example of a playlist out there on github, but its so old and has hundreds of lines of code and is running into issues without even changing anything.

For all its worth, I'll copy and paste my current code in here in hopes I can get some help. Would be extremely appreciated.

const [listView, setListView] = useState(true);
  const [ayahData, setAyahData] = useState([]);
  const [sound, setSound] = useState(null);
  const [number, setNumber] = useState(null);

  useEffect(() => {
    return sound
      ? () => {
          sound.unloadAsync();
        }
      : undefined;
  }, [sound]);

  async function playSound(soundURL) {
    const { sound } = await Audio.Sound.createAsync({
      uri: soundURL,
    });
    setSound(sound);

    await sound.playAsync();
  }

The code above works if I click on a specific audio, but obviously in its current state wont automatically move to the next.

Small hints like how to properly listen for an audio ending with my current block of code would be more than enough.

Hey
  • 43
  • 5
  • Look at didJustFinish here: https://docs.expo.dev/versions/latest/sdk/av/ – jnpdx Sep 20 '22 at 13:20
  • hey @jnpdx thank you, that looks very promising. I just can't seem to understand where the _onPlaybackStatusUpdate comes into play, like how does it connect to my sound – Hey Sep 20 '22 at 13:34
  • From that page: playbackObject.setOnPlaybackStatusUpdate(this._onPlaybackStatusUpdate); – jnpdx Sep 20 '22 at 13:48
  • is there a way to do this with functional components instead of class based? I have no idea how this would work with the code base they provided unfortunately – Hey Sep 20 '22 at 13:53
  • You can do this in a useEffect – jnpdx Sep 20 '22 at 13:55
  • :/ dont really know what you mean by that, could you give me a very short example of code please? that would probably fix everything – Hey Sep 20 '22 at 14:53

0 Answers0