react-native-sound
react-native-sound copied to clipboard
How to avoid multiple playing sound in same time ?
:beetle: Description
I want to stop the current playing sound when i start playing an other one
:beetle: What have you tried?
:beetle: Please post your code:
// Please post your code
:bulb: Possible solution
Is your issue with...
- [ ] iOS
- [ ] 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:
- React Native:
- iOS:
- Android:
- Windows:
Does the problem occur on...
- [ ] Simulator
- [x] Device
If your problem is happening on a device, which device?
- Device:
Iam unable to stop multiple audios,please help me out.
const onStartPlay = (uri) => { if (!soundPlayer) { const player = new Sound(uri, '', (error) => { if (error) { console.log('Error loading audio:', error); } else { player.play(() => { setIsPlaying(false); setPlayLottie(false) setSoundPlayer(null); }); } }); setIsPlaying(true); setPlayLottie(true); setSoundPlayer(player); } else { soundPlayer.pause() setIsPlaying(false); setPlayLottie(false) setSoundPlayer(null);
}
};