hyochan / react-native-audio-recorder-player

react-native native module for audio recorder and player.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

addPlayBackListener flood

sayem314 opened this issue · comments

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;
  }, []);

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.

commented

Closes in #286 with 3.0.0-beta.2 release!