MediaPlayer throws illegalstateexception
<p><strong>edit3:
Ahaaa! MP crashed when SP "gives sample 14 not READY"...</strong></p>

<p>edit 2:
I also have a SoundPool in my activity what plays short sound effects and, obviously, it somehow kills the MediaPlayer.
Like the MediaPlayer loads, plays about a second and then dies when SP is loaded.
If I load MediaPlayer at a later time, when SP is already loaded, MP will start playing fine, but will die if I play a few sound FX in SP...</p>

<p>old:
I'm trying to play a music sound file, about 2 minutes long...</p>

<pre><code>    try {
        MediaPlayer mp = MediaPlayer.create(main.this, R.raw.naturesounds );
        mp.prepare();
        mp.start();
    } catch (IllegalStateException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
</code></pre>

<p>yet it throws </p>

<pre><code>06-29 16:50:52.359: E/MediaPlayer(3772): prepareAsync called in state 8
06-29 16:50:52.359: W/System.err(3772): java.lang.IllegalStateException
06-29 16:50:52.359: W/System.err(3772):     at android.media.MediaPlayer.prepare(Native Method)
06-29 16:50:52.359: W/System.err(3772):     at engineDemo.com.main.fillWorld(main.java:132)
06-29 16:50:52.359: W/System.err(3772):     at engineDemo.com.main.onCreate(main.java:83)
06-29 16:50:52.359: W/System.err(3772):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
06-29 16:50:52.359: W/System.err(3772):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
06-29 16:50:52.359: W/System.err(3772):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
06-29 16:50:52.359: W/System.err(3772):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
06-29 16:50:52.359: W/System.err(3772):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
06-29 16:50:52.359: W/System.err(3772):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-29 16:50:52.359: W/System.err(3772):     at android.os.Looper.loop(Looper.java:130)
06-29 16:50:52.359: W/System.err(3772):     at android.app.ActivityThread.main(ActivityThread.java:3683)
06-29 16:50:52.359: W/System.err(3772):     at java.lang.reflect.Method.invokeNative(Native Method)
06-29 16:50:52.359: W/System.err(3772):     at java.lang.reflect.Method.invoke(Method.java:507)
06-29 16:50:52.359: W/System.err(3772):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
06-29 16:50:52.363: W/System.err(3772):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
06-29 16:50:52.363: W/System.err(3772):     at dalvik.system.NativeStart.main(Native Method)
</code></pre>

<p>Any ideas what might be wrong or what's the best way to play background music?</p>

<p>Thanks!</p>

<p>edit:</p>

<p>edited like this</p>

<pre><code>    final MediaPlayer mediaPlayer = MediaPlayer.create(this, R.raw.naturesounds);
    mediaPlayer.setOnPreparedListener(new OnPreparedListener(){

        public void onPrepared(MediaPlayer arg0) {
            Log.e("ready!","ready!");
            mediaPlayer.start();

        }} );
</code></pre>

<p>it does show the Log, but still nothing plays...</p>
