react-native-volume-controller
react-native-volume-controller copied to clipboard
Error getting volume on update
In your slider, when updating volume in state, should be parse to float.
Line 16: this.setState({volume_value:parseFloat(evt.volume)});
And isn't the listener should be remove when component unmount ?
`code
componentDidMount() {
this.DeviceEventVolumeListener = DeviceEventEmitter.addListener(
'VolumeControllerValueUpdatedEvent', (evt) => {
console.log("update view volume "+evt.volume);
this.setState({volume_value:parseFloat(evt.volume)});
}
);
ReactNativeVolumeController.update();
}
componentWillUnmount() {
this.DeviceEventVolumeListener.remove();
}`
I updated the code, and now have a other way to get this value.
onValueChange={ (value)=>{ this.isDragging = true; ReactNativeVolumeController.change(value); setTimeout(()=>{ this.isDragging = false; }
What is the version are you using?