IllegalStateException for MediaPlayer.prepareAsync

"prepareAsync called in state 8" means the Mediaplayer is already prepared.

are you calling mp.prepare(); in your code?


mp = MediaPlayer.create(...); is already preparing the MediaPlayer returned, so you cannot call prepare (or its variants) again (and there is no need for onPreparedListener as well).


Your updated question:

  1. Check whether you have INTERNET permission in your AndroidManifest.xml
  2. Check whether you have some data connection enabled, as you want to stream from the internet
  3. What do you mean with "this solution also fails"? Does it throw an IllegalStateException? From what I see, it just won't do anything at all, because you register your OnPreparedListener after the MediaPlayer object has prepared itself, causing the onPrepared() method never to be called.

A better approach would be to write:

MediaPlayer mp = new MediaPlayer();  
mp.setDataSource("http://.../movie.mp4");  
mp.setOnPreparedListener(this);  
mp.prepareAsync();