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 <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to