Issue #800 has been open since 2008. It's unbelievable that three years later, one still cannot determine the state of the MediaPlayer.
I hate to kvetch, but Android makes me kvetch more that just about any platform. Regards P. V. Nasby On Sat, Nov 27, 2010 at 7:38 AM, Jason <jason.poli...@gmail.com> wrote: > Thanks for the advice. I had already modeled the state transitions > using the listeners, however I suspect there is (was) a problem with > the rules I had implemented in this regard. > > Because the call to prepareAsync returns immediately, I think a > subsequent call to prepareAsync was coming in and failing due to a > missed state check in the code. > > I also realized that I don't actually need to call prepareAsync in > most cases anyway. Because I am really just wanting to "reset" the > audio track to be played again, I can just call seekTo(0) which is > much faster. > > In the end.. as usual.. it was my crufty code that was the problem! > > Thanks again, > > Jason. > > -- > Droid Odyssey! A new game for Android > http://www.carboncrystal.com/droid-odyssey/ > > On Nov 27, 6:59 am, joebowbeer <joe.bowb...@gmail.com> wrote: >> Do you have an error listener registered? Does it give you more >> information? >> >> According to the state diagram, stop() is not available in all states. >> Perhaps you're calling stop() in an invalid state, causing the player >> to transition to the Error state, at which point prepareAsync would >> fail: >> >> http://developer.android.com/reference/android/media/MediaPlayer.html >> >> In my experience with media player, it's best not to assume that a >> state transition has happened until one of the listeners tells you. >> >> Also, if you have the luxury of creating a new MediaPlayer instead of >> trying to stop and reuse the current player, I think you'll receive >> fewer error reports. >> >> On Nov 23, 1:16 am, Jason Polites <jason.poli...@gmail.com> wrote: >> >> >> >> >> >> >> >> > Hi folks, >> >> > Some time ago I posted an issue relating to an IllegalStateException >> > in the Media Player (http://groups.google.com/group/android-developers/ >> > browse_thread/thread/46c7c2cd4f4a6958/5551d47aac93632c) >> >> > I have just launched the app into the "wild" and this error is >> > flooding in. >> >> > I just can't seem to fathom why.. here's the code: >> >> > if(mp != null) { >> > mp.stop(); >> > mp.prepareAsync(); >> >> > } >> >> > (mp is a MediaPlayer instance BTW). >> >> > According to the doco, prepareAsync is valid for {Initialized, >> > Stopped} states.. but I just can't see how it could be in any state >> > other than stopped?? >> >> > The trace is: >> >> > java.lang.IllegalStateException >> > at android.media.MediaPlayer.prepareAsync(Native Method) >> > .. the line of code mentioned above follows. >> >> > Is it possible that stop() is not synchronous? Can't seem to see >> > anything in the doco stating this. >> >> > Anyone got any ideas? >> >> > P.S. >> >> > I'm seeing this on a wide range of devices, but all so far are version >> > 2.1-update1 >> >> > -- >> > Droid Odyssey! A new game for >> > Androidhttp://www.carboncrystal.com/droid-odyssey/ > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en