Android MediaPlayer looping issues.

Looping isn’t seamless

I’m finding that some parts of the Android MediaPlayer are perhaps harder to work on.  I’ve been putting some code together to endlessly loop a short 30 second clip for the background of the Bloom project.

The code looks like this:

public class Background {
MediaPlayer mp1;

Background (Context con) {
mp1 = MediaPlayer.create(context, R.raw.soundsample1);

Play() {

The simplicity is breathtaking.  Create an instance of a MediaPlayer object in the constructor then when the user presses “play”, start the sound.  Nice.

The only problem is that there is a discernible gap between the end of the plays in the loop.  It’s about 8 hundredths of a second which isn’t much, but it annoys me and that’s all it takes.

Next up – my attempt to fix this through threading.

More later…

Comments are closed.