Question

Given the diagram http://developer.android.com/reference/android/media/MediaPlayer.html#Valid_and_Invalid_States when the mediaplayer object is playing and then stops playing (because song finished ofc), does it enter the stopped state or is it still in started? Thanks a lot

Was it helpful?

Solution

Quote from the link you shared:

When the playback reaches the end of stream, the playback completes.

If the looping mode was being set to true with setLooping(boolean), the MediaPlayer object shall remain in the Started state.

If the looping mode was set to false , the player engine calls a user supplied callback method, OnCompletion.onCompletion(), if a OnCompletionListener is registered beforehand via setOnCompletionListener(OnCompletionListener). The invoke of the callback signals that the object is now in the PlaybackCompleted state.

While in the PlaybackCompleted state, calling start() can restart the playback from the beginning of the audio/video source.

So it enters PlaybackCompletedState and then stop state after playback is completed. If looping is set to true, it remains in started state.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top