addPlayBackListener flood
sayem314 opened this issue · 2 comments
sayem314 commented
Version of react-native-audio-recorder-player
2.6.2
Platforms you faced the error (IOS or Android or both?)
Tested only on Android
Expected behavior
Should not flood and should only execute when playing
Actual behavior
The player event is fired too much in a row, it even also gets fired when the player is paused. The event should throttle and only fire when it's playing.
Steps to reproduce the behavior
useEffect(() => {
Player.addPlayBackListener((e: any) => {
console.log(e);
});
return Player.removePlayBackListener;
}, []);
sayem314 commented
Okay so setting Player.setSubscriptionDuration(1);
does throttle subscription but there should be better defaults like 500ms or 1sec. However, it's still a valid issue since the subscription is fired even when in the player is in a pause state.