Mediaplayer.getduration() Returns 0 After Setdatasource And Crashes App
I honestly have no idea why this is happening, when the code makes sense and following tutorials the same way. I first set the data source and surround it in a try and catch, set t
Solution 1:
You should call mediaPlayer.getDuration() once data source is prepared that is inside OnPreparedListener call back
mediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mediaPlayer) {
mediaPlayer.getDuration()
mediaPlayer.start();
}
});
Post a Comment for "Mediaplayer.getduration() Returns 0 After Setdatasource And Crashes App"