Mediaplayer is null on resume.
eman747 opened this issue · 0 comments
eman747 commented
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);
};