I'm using react-native-sound library in order to play one track multiple times. Here is my code:
const playAudio = () => {
sound.setNumberOfLoops(2).play()
}
playAudio()
I wonder why the track is played infinite times.
I'm using react-native-sound library in order to play one track multiple times. Here is my code:
const playAudio = () => {
sound.setNumberOfLoops(2).play()
}
playAudio()
I wonder why the track is played infinite times.
The playAudio()
shouldn’t be used directly. Use this
useEffect( () => {
playAudio()
}, [] )
const playAudio = () => {
// Loop indefinitely until stop() is called
sound.setNumberOfLoops(-1).play()
}