I'm using 50 different sound files. it works normally but on my 14th or 15th try it no longer plays the audio files. (I am using android device)
const animalSound = new Sound( selectedAnimals.soundUrl ||"snake.mp3", null, error => {
if (error) console.log("Can't play sound. ", error);
})
const handlePlaySound = () => {
animalSound.setVolume(1);
animalSound.play(() => {
animalSound.release();
});
};
const handleStopSound = id => {
animalSound.stop()
}
I used
expo-av
for sound, which can also be used in a bare react-native project. (https://github.com/expo/expo/tree/main/packages/expo-av)I made this hook which allows you to play the sound and aslo clears up the resources for you so you don't have to worry about it.
All you have to do to use the sound is this