Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IllegalStateException calling MediaPlayer.reset()

Tags:

The documentation for the Android MediaPlayer shows that there are no invalid states for the reset() call: http://developer.android.com/reference/android/media/MediaPlayer.html#Valid_and_Invalid_States (the invalid states are listed as {}, or "none.").

However, I have seen an IllegalStateException thrown while calling reset():

java.lang.IllegalStateException at android.media.MediaPlayer._reset(Native Method) at android.media.MediaPlayer.reset(MediaPlayer.java:1061) at com.example.android.player.AsyncPlayer$AsyncHandler.handleMessage(AsyncPlayer.java:654) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.os.HandlerThread.run(HandlerThread.java:60) 

Is the documentation incorrect?

like image 256
skyler Avatar asked Jul 06 '11 15:07

skyler


1 Answers

Hard to say without seeing your code but I think you may be calling reset() after you call release() ?

The documentation states

When a MediaPlayer object is just created using new or after reset() is called, it is in the Idle state; and after release() is called, it is in the End state. Between these two states is the life cycle of the MediaPlayer object.

You may be calling reset outside of the valid life cycle.

like image 185
denizmveli Avatar answered Oct 30 '22 07:10

denizmveli