title: Media Player how to recover when create fails?
body: <p>I have an app that plays randomly every second 1 of 20 different sounds . After almost 1000 successful times the media player create function starts to return always null. The problem remains even when I leave the app and I start it again. The only solution is when I install the app again or I switch off and on the device.</p>
  
  <p>Is there any method to recover from this state? If I do release or reset, media player was already null and they produce an exception.</p>
  
  <p>The sequence I do every second is the following:</p>
  
  <pre><code>if (mp != null)
  {   
      if (mp.isPlaying()) 
      {
         mp.stop();   
      }   
      if (mp != null) mp.release();   
      if (mp != null) mp = null;  
  }   
  
  mp = MediaPlayer.create(this, R.raw.sound);
  
  if (mp !=null)
  {
     mp.setOnPreparedListener(new MediaPlayer.OnPreparedListener() 
     {           
        public void onPrepared(MediaPlayer mp) 
        {
      if (mp != null) mp.start();
        }
     };
   }
   else
   {
      // error, what should I do here to recover from this situation?
   }
  </code></pre>