title: MediaPlayer prepareAsync() method throws IllegalStateException
body: <p>I'm trying to use MediaPlayer to stream music from a web-server, it looks like this:</p>
  
  <pre><code>try {
                  MediaPlayer player = new MediaPlayer();
                  player.setAudioStreamType(AudioManager.STREAM_MUSIC);
                  player.setDataSource(audioUrl);
                  player.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
                      @Override
                      public void onPrepared(MediaPlayer mp) {
                          mp.start();
                      }
                  });
                  player.prepareAsync();
  
              } catch (Exception e) {
                  Log.d("PLAY", "can't play it");
                  // TODO: handle exception
              }
  </code></pre>
  
  <p>Unfortinatelly <code>prepareAsync()</code> always throws IllegalStateException when debugging, so I never get to the <code>onPrepared()</code> method. I tried to use <code>prepare()</code> instead of <code>prepareAsync()</code>, but it throws IOException. I looked up this problem, but everything I could find was to add 
  <code>android.permission.INTERNET</code> to the manifest or to invoke <code>start()</code> from <code>setOnPrepareListener</code> (which I've already done). </p>
  
  <p>The weirdest thing is that my app works correctly when it's running inspite of the fact that I never invoke start() method during debugging. Does anyone know what this means? </p>
  
  <p>EDIT 1:
  Here is what I got using logcat on Debug level (I hope that's what you meant):</p>
  
  <pre><code>D/OpenGLRenderer: Enabling debug mode 0
  D/dalvikvm: GC_FOR_ALLOC freed 2292K, 18% free 11063K/13392K, paused 14ms, total 14ms
  E/MediaPlayer: prepareAsync called in state 1
  D/dalvikvm:   JDWP invocation returning with exceptObj=0x43d24770 (Ljava/lang/IllegalStateException;)
  E/MediaPlayer: prepareAsync called in state 1
  D/dalvikvm:   JDWP invocation returning with exceptObj=0x43af0d50 (Ljava/lang/IllegalStateException;)
  E/MediaPlayer: prepareAsync called in state 4
  03-05 21:03:20.316 5459-5459/com.example.vkmusic D/dalvikvm:   JDWP invocation returning with exceptObj=0x43dee6c0 (Ljava/lang/IllegalStateException;)
  E/MediaPlayer: prepareAsync called in state 8
  </code></pre>
  
  <p>EDIT 2: Alright, it turned out that exceptions are thrown during debugging only if I put a method into Watches otherwise it works without any exceptions. For example if I put <code>player.setDataSource(audioUrl)</code> there, it throws Exception when it reach the same line in the code. Totally the same thing happens to <code>player.prepareAsync()</code> and now I'm totally confused. Why is that happening?</p>