I have installed:
mSeekBar.setMax(mp.getDuration());
After completing Audiofile, I get:
player.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { public void onCompletion(MediaPlayer mediaPlayer) { Log.e("onComplete>>", ""+mediaPlayer.getCurrentPosition()); // mediaPlayer.getCurrentPosition() = 8192 Log.e("getDuration", ""+mediaPlayer.getDuration()); // mediaPlayer.getDuration() = 8480 if(mediaPlayer.getCurrentPosition()>=mediaPlayer.getDuration()) { // Why never get called??? } } });
So, why does the current position of MediaPlayer not reach the total duration of the audio file?
Or technically we can say:
Why not?
mediaPlayer.getCurrentPosition()==mediaPlayer.getDuration()
Why always
mediaPlayer.getCurrentPosition () <mediaPlayer.getDuration () in an OnCompletion listener?
Example:
I have a Play symbol to start the player. Now, when I click the play symbol, it is converted to the Pause symbol.
I have a maxduration file audiodfile.
Now I want to convert the Pause symbol to Play Symbol when the audio file is fully played. So what I am doing is checking:
if(mediaPlayer.getCurrentPosition()>=mediaPlayer.getDuration()) {
android media-player android-mediaplayer android-seekbar
Sagar shah
source share