Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Small pause between looping MediaPlayer

I'm trying to loop a ~30 seconds audio track multiple times. I'm using a MediaPlayer to play the sounds, here is the code where its created:

mAnimalMediaPlayer = MediaPlayer.create(mContext, fish.getSound());

I then call:

mAnimalMediaPlayer.setLooping(true);
mAnimalMediaPlayer.start();

when a play button is clicked. When the track loops, there is a small but noticeable pause between the track ending and the new loop beginning. I am positive that the audio file im using does not contain any actual pause.

Here is an android bug report which has been up for some time: https://code.google.com/p/android/issues/detail?id=18756

I've tried a few workarounds (such as using .ogg files instead of .mp3) but the problem persists.

I'm looking for any possible workaround that will allow me to seamlessly loop the playback multiple times.

like image 673
Orbit Avatar asked Jun 29 '26 12:06

Orbit


1 Answers

There is a very noticeable pause. However, I have just discovered through experimentation on an emulator running level 25 that if one prepares two identical players and alternately starts them one after the other when the other has finished then the gap becomes much more difficult to hear.

like image 106
user731448156122 Avatar answered Jul 01 '26 02:07

user731448156122



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!