Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mediaplayer is null on resume. #626

Open
eman747 opened this issue Aug 26, 2024 · 0 comments
Open

Mediaplayer is null on resume. #626

eman747 opened this issue Aug 26, 2024 · 0 comments

Comments

@eman747
Copy link

eman747 commented Aug 26, 2024

When audio reaches after 80% and is paused after resuming this error comes in android.
const onStartPlay = async (): Promise => {
// console.log('onStartPlay', path.current);

// console.log(state);
try {
  setPlay(true);
  if (playWidth !== 0) {
    // console.log('not zero');
    await audioRecorderPlayer.resumePlayer();
  }

  const msg = await audioRecorderPlayer.startPlayer(path.current);

  const volume = await audioRecorderPlayer.setVolume(1.0);

  audioRecorderPlayer.addPlayBackListener((e: PlayBackType) => {
    setState(prevState => ({
      ...prevState,
      currentPositionSec: e.currentPosition,
      currentDurationSec: e.duration,
      playTime: audioRecorderPlayer.mmssss(Math.floor(e.currentPosition)),
      duration: audioRecorderPlayer.mmssss(Math.floor(e.duration)),
    }));

    if (e.currentPosition >= e.duration) {
      onFinish();
    }
  });
} catch (err) {
  // console.log('startPlayer error', err);
}

};
const onPausePlay = async (): Promise => {
await audioRecorderPlayer.pausePlayer();
setPlay(false);
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@eman747 and others