I’m writing an audio player using MediaPlayer that allows the user to skip the actual tune. A skip request might occur at any time, including between a call to MediaPlayer.prepareAsync and the upcoming onPrepared callback. The doc says:
It is important to note that the Preparing state is a transient state, and the behavior of calling any method with side effect while a MediaPlayer object is in the Preparing state is undefined.
Does that include calls to reset, or even to release? Because if it so, then I would either have to wait for the onPrepared callback to reuse the MediaPlayer or allocate a brand new MediaPlayer if I don’t want to wait and release the obsolete one on the onPrepared callback, right?
In my opinion i will follow the advice in the docs, i found several issues with player in different devices (in some devices is not stable at all reusing the same player).
I think a good option is to have to players allocated, and switch between them when user skips a tune, then you wait for the original player to arrive to prepared state and then you reset it safely.