zmxv / react-native-sound

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

Sounds stops and start to play again in Lenovo Smartphones #281

Open marcusviniciusf opened 6 years ago

marcusviniciusf commented 6 years ago

Hello guys, I have a trouble specific in the lenovo devices. When I stop the sound, its start again automatically. This problems occurs only on this device.. My code

playOrStop() { if (!this.state.play) { return this.play(); } return this.stop(); } play() { const { ventilador } = this.props; console.log(ventilador); ventilador.setVolume(0.5); ventilador.setNumberOfLoops(-1); ventilador.play(success => { if (success) { console.log('successfully finished playing'); } else { console.log('playback failed due to audio decoding errors'); ventilador.reset(); } }); this.handleNotification(); this.setState({ btnStart: btnPowerOn, play: true }); } stop() { console.log('no stop'); this.props.ventilador.stop(); this.setState({ btnStart: btnPowerOff, play: false }); }

ghost commented 6 years ago

I think you can set its volume to 0 when it stops. Then even if it plays again, it won't be heard.

Add setVolume to 0

smnodame commented 6 years ago

I found on my device also. @jamesharvey2 I just did like your suggestion, it's work but looks like hacked. but it's okay for me because we run it with instant :smile: