Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve gapless audio playback between looping on Android

I have tried almost every methods but failed to achieve gapless audio playback between looping a single track.

Steps i have tried n failed :

  1. Different audio file formats .mp3 .wav .ogg using both setLooping(true) and setOnCompletionListener methods but failed.
  2. Creating two mediaplayers and looping one after another using setOnCompletionListenersame failed to loop without gaps.
  3. Using setNextMediaPlayer(nextmp) it worked, but it merges only two different or same audio tracks without any gap and stops playing, But i don't know how to loop it for-ever .

Any 1 please help me, Thanks in advance .

like image 515
Sai Avatar asked Oct 21 '22 20:10

Sai


1 Answers

Just idea. Make loop between 2 media players. Probably you will need to do extra work when MediaPlayer object compleate playback to prepare for playback again in onCompleation().

Disable loop for both MediaPlayer objects.

prevMedia.setNextMediaPlayer(nextmp);
nextmp.setNextMediaPlayer(prevMedia);
like image 149
dasar Avatar answered Oct 24 '22 17:10

dasar