I'm several audios on FlatList and I'm trying to play one by one. Until in some moment, it stops and does not work anymore.
I'm debugging and the audio looks like load normally, just sound doesn't come out.
My code:
async playSound (url) {
await this.loadSound(url)
this.player.play((success) => {
if (!success) {
this.player.reset()
}
this.player.release()
})
}
loadSound (url) {
return new Promise((resolve, reject) => {
Sound.setCategory('Playback', true)
this.player = new Sound(url, undefined, (error) => {
if (error) {
reject(error)
}
resolve()
})
})
}
Did anybody have this problem and can help me?
To complement, my poc's interface

I'm only had calling .release() when the audio has ended
so, I'm also just calling when pausing like .pause.release() and works
My actual code, maybe would it help others:
import Sound from 'react-native-sound'
class AudioManager {
constructor () {
this.player = null
this.currentAudio = null
}
async play (url, onFinishCallback) {
if (this.currentAudio !== url) {
await this.loadSound(url)
this.currentAudio = url
}
this.resume(onFinishCallback)
}
pause () {
if (this.player === null) return
this.player.pause()
}
resume (onFinishCallback) {
this.player.play((success) => {
if (!success) {
this.player.reset()
}
this.release()
onFinishCallback()
})
}
loadSound (url) {
this.release()
Sound.setCategory('Playback', true)
return new Promise((resolve, reject) => {
this.player = new Sound(url, undefined, (error) => {
if (error) {
reject(error)
}
resolve()
})
})
}
release () {
if (this.player === null) return
this.player.pause().release()
this.currentAudio = null
}
}
export default new AudioManager()
Most helpful comment
I'm only had calling .release() when the audio has ended
so, I'm also just calling when pausing like .pause.release() and works
My actual code, maybe would it help others: