title: Not able to achieve Gapless audio looping so far on Android
body: <p>I have tried almost every method but I've failed to achieve gapless audio playback between looping a single track with a duration of 10-15 seconds.</p>
  
  <p>Steps I've tried and failed :</p>
  
  <ol>
  <li><p>Different audio file formats <code>.mp3</code> <code>.wav</code> <code>.ogg</code> using
  <code>setLooping(true)</code>:</p>
  
  <pre><code>MediaPlayer mp1 = MediaPlayer.create(MainActivity.this, R.raw.track1);
  mp1.setLooping(true);
  mp1.start();
  </code></pre></li>
  <li><p>Creating two mediaplayers and looping one after another using
  <code>setOnCompletionListener</code>same failed to loop without gaps.</p></li>
  <li><p>Using <code>setNextMediaPlayer(nextmp)</code> some how it works but only two loops is possible. We have to prepare and start again after the completion of previous two loops. </p>
  
  <pre><code>mp1.start();
  mp1.setNextMediaPlayer(mp2);
  </code></pre></li>
  <li><p><strong>Update:</strong>
  Result of @Jeff Mixon answer:
  <a href="https://stackoverflow.com/questions/29753960/mediaplayer-looping-stops-with-an-error-android">Mediaplayer looping stops with an error Android</a>. 
  Jeff Mixon works fine but only for 10 or 20 loops after that, due to some garbage collection issue the Mediaplayers stops immediately leaving the logs as posted below. I'm really kind of stuck here for 2 years. Thanks in advance.</p>
  
  <pre><code>E/MediaPlayer(24311): error (1, -38)
  E/MediaPlayer(23256): Error(1,-1007)
  E/MediaPlayer(23546): Error (1,-2147483648)
  </code></pre></li>
  </ol>