zmxv / react-native-sound

React Native module for playing sound clips
MIT License
2.78k stars 748 forks source link

setNumberOfLoops(-1) only play 3 - 4 times #757

Open Rc85 opened 2 years ago

Rc85 commented 2 years ago

:beetle: Description

setNumberOfLoops(-1) only play 3 times

:beetle: What is the observed behavior?

setNumberOfLoops(-1) only play 3 times

:beetle: What is the expected behavior?

Should loop infinitely until stop() is called.

:beetle: Please post your code:

const newOrderAlert = new Sound('new_order2.mp3', Sound.MAIN_BUNDLE);

newOrderAlert.setNumberOfLoops(-1);

newOrderAlert.play();

:bulb: Does the problem have a test case?

:bulb: **Possible solution**

:bulb: Is there a workaround?

:bulb: If the bug is confirmed, would you be willing to create a pull request?

Is your issue with...

Are you using...

Which versions are you using?

Does the problem occur on...

If your problem is happening on a device, which device?

Rc85 commented 2 years ago

Are there nobody running into this issue or similar issue with not being able to set infinite loop on Android?

Digicrest commented 2 years ago

Opposite problem for me, setting a finite number and loops infinitely.

let sound = new Sound(sounds.sfx.knock, err => { sound.setNumberOfLoops(5).play((isFinished) => { console.log('finished') }) })

Rc85 commented 2 years ago

Finally figured it out. Had to load sound like this.

const newOrderAlert = new Sound('new_order2.mp3', Sound.MAIN_BUNDLE, () => {
  newOrderAlert.setNumberOfLoops(-1);
});
onlyling commented 2 years ago

.wav file it is ok 😂