react-native-sound icon indicating copy to clipboard operation
react-native-sound copied to clipboard

setNumberOfLoops(-1) only play 3 - 4 times

Open Rc85 opened this issue 4 years ago • 4 comments

: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...

  • [ ] iOS
  • [x] Android
  • [ ] Windows

Are you using...

  • [x] React Native CLI (e.g. react-native run-android)
  • [ ] Expo
  • [ ] Other: (please specify)

Which versions are you using?

  • React Native Sound: ^0.11.1
  • React Native: ^0.66.0
  • iOS:
  • Android: 10
  • Windows:

Does the problem occur on...

  • [ ] Simulator
  • [x] Device

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

  • Device: Samsung Galaxy Tab A

Rc85 avatar Oct 08 '21 04:10 Rc85

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

Rc85 avatar Nov 08 '21 10:11 Rc85

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') }) })

  • Device: Android Emulator (Pixel_5_API_31)
  • react-native: 0.64.1
  • react-native-sound: 0.11.0

Nyxalium avatar Nov 09 '21 17:11 Nyxalium

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

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

Rc85 avatar Nov 11 '21 21:11 Rc85

.wav file it is ok 😂

onlyling avatar May 31 '22 07:05 onlyling