title: MediaPlayer start->stop->start for MIDI files
body: <p>I am seeing a problem with MediaPlayer, trying to do the next sequence start()->stop()->start() for MIDI files gives me an error.</p>
  
  <p>By looking at the <a href="http://developer.android.com/reference/android/media/MediaPlayer.html" rel="nofollow">MediaPlayer state diagram,</a> the sequence should work with the next code:</p>
  
  <pre><code>void experiment() throws IllegalArgumentException, SecurityException, IllegalStateException, IOException {
      Context context = this;
      int resid = R.raw.teddybear;
      String packageName = getResources().getResourcePackageName(resid);
      Uri uri = Uri.parse("android.resource://" + packageName + "/"  + resid);
      MediaPlayer mp = new MediaPlayer();
      mp.setDataSource(context, uri);
      mp.prepare();
      mp.start();
      mp.stop();
      mp.prepare();
      mp.start();
  }
  </code></pre>
  
  <p>Here is the error is get from the call to the second prepare:</p>
  
  <p>java.io.IOException: Prepare failed.: status=0xFFFFFFFD</p>
  
  <p>This problem does not exist for other sound files.</p>
  
  <p>Is anyone experiencing this also? Am i doing something wrong?</p>
  
  <p>I am not trying to find walk-around - got plenty :)</p>
  
  <p>Things tried:</p>
  
  <ul>
  <li><p>removing the stop and stop&amp;prepare&amp;start allows this stream to be played.</p></li>
  <li><p>I've heard that the MediaPlayer is not immediately get updated for its state, so i added sleeps between the methods - still same issue.</p></li>
  <li><p>Changing the file type solved the issue.</p></li>
  <li><p>trying several MIDI file yield the same result.</p></li>
  <li><p>registering an OnError also did not worked - he was not called</p></li>
  </ul>
  
  <p>Can it be that this is a bug?
  Thanks.</p>