title: Android MediaPlayer onPrepared Method sometimes not called
body: <p>I have a musicPlayer app and thus a SongPlayer class which implements the android MediaPlayer. The MediaPlayer runs as a Service. </p>
  
  <p>Everything works fine!! The app plays all day long normally. But once in 24h approximately there comes a random song and the onPrepared method is never called. </p>
  
  <p>The logic flow is as follows:</p>
  
  <p>1) i create the mediaplayer (if not yet created)
  2) i set the datasource 
  3) i prepare the mediaplayer as async
  4) in the onPrepared method i call the START method</p>
  
  <p>Since the onprepared method is not called the START method is not called and the music player nevers starts palying the next song.</p>
  
  <p>I made some analysis and it has nothing to do with a particular song, it happens on radon songs on random time. </p>
  
  <p>No error is ever reported. </p>
  
  <p>Any ideas where the problem might be????</p>
  
  <p>Any idea on how to check if the onPrepared method is NOT CALLED? As a backup plan?</p>
  
  <p>A summarization of the Code. </p>
  
  <p>The code is much complexer since other methods are implemented (onComplete, onError, etc.) but these i have not included since they are not needed.</p>
  
  <pre><code>if(MyGlobalAudioPlayer.mediaplayer == null){
            MyGlobalAudioPlayer.mediaplayer = new MediaPlayer();}
  
  MyGlobalAudioPlayer.mediaplayer.reset();
  
  MyGlobalAudioPlayer.mediaplayer.setDataSource("http://"+SongPlayer.modS+SongPlayer.path);
  
  MyGlobalAudioPlayer.mediaplayer.prepareAsync();
  
  MyGlobalAudioPlayer.mediaplayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
  
              public void onPrepared(MediaPlayer mp) {
  
                  Log.e("OLE", "playThisSong onPREPARED");
  
                 MyGlobalAudioPlayer.mediaplayer = mp;
                 MyGlobalAudioPlayer.mediaplayer.start();
              }
  });
  </code></pre>
  
  <p>PROBLEM SOLVED:</p>
  
  <p>Found the source of the problem. It was not with the MediaPlayer class. It was some other process in my app.</p>
  
  <p>I have a service which every 60s makes an update to the server. In this method i also check if the player is really playing. If not i start something else. </p>
  
  <p>It happend in a while that this update occured the same moment the MediaPalyer wanted to prepare the song. And the method was faster, thus the onPrepared was never called. </p>