I wrote a small music playback control test application. I have a play, pause, stop and rewind button. My issue is that that
player.stop();
is behaving the same exact way as
player.pause();
I am calling player.prepare() right after player.stop() so that i can have the player instance ready for start() operation.
I do not see any errors [IOexceptions or IllegalStateExceptions] being raised while calling the prepare() after i do a stop(). Also, i am not calling any seekTo(0) after stop(). So, i am not setting the position back to the beginning of the song.
I am using a Nexus Google One phone running 2.3.4.
Any idea if i am doing something stupid or if what i am observing is actually how the state machine was built.
TIA.
doesn’t the state diagram http://developer.android.com/reference/android/media/MediaPlayer.html
states that stop means "stay in stopped state" ?
There’s no affirmation that
stop()should change theCurrentPosition.There’s no affirmation that calling the
prepare()should change theCurrentPosition.So, to go to the beginning of the music, you should mannualy set its position.
But I agree with you. Since the
pause()method states it will resume playing from the current position, I’d expect it get back to the beginning whenstop()is called.And it has some impact when you need to call the
prepare()so
stop()needs to callprepare()that can make it take longer, whilepause()has less impact: you can call thestart()right after.