2

When I play the first song then it's absolutely fine but next time I get the error message of title text and I got the error in mPlayer.prepare(), please extend your help...

mPlayer.reset();
mPlayer.setOnCompletionListener(this);
mPlayer.setOnErrorListener(this); mPlayer.setDataSource(filePath);
mPlayer.prepare(); mPlayer.start(); isPlaying = true;
playPauseBtn.setEnabled(true); navigationbar.setEnabled(true);
totalMediaTime = mPlayer.getDuration() / 1000;
durationTextView.setText(Helper.getTimeFromSecods(totalMediaTime));
navigationbar.setMax(mPlayer.getDuration());

and I get error code 38... No idea what's it..

kamal_tech_view
  • 4,235
  • 4
  • 28
  • 49

1 Answers1

2

You are trying to get mediaPlayer.getDuration() before the preparation is complete. Use the setOnPreparedListener() method to set a preparation listener and call the getDuration() method only after the preparation is complete.