IllegalStateException for MediaPlayer.prepareAsync
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).
"prepareAsync called in state 8" means the Mediaplayer is already prepared.
are you calling mp.prepare();
in your code?
Your updated question:
- Check whether you have INTERNET permission in your
AndroidManifest.xml
- Check whether you have some data connection enabled, as you want to stream from the internet
- 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();