0

I have an mp3 file that should be played repeatedly.

I simply use this code:

mediaPlayer = MediaPlayer.create(_context, scanner);
mediaPlayer.setLooping(true);
mediaPlayer.start();

I have tested it on Android Studio simulator and it works fine, then I have tested it on my own phone and it works fine as well BUT when I connect my phone with a speaker device over Bluetooth, the sound will be played well at the first time but when it's getting replayed, it always starts after about 1 second. The duration of my mp3 file is 4 seconds. So there is always 1 second that is missing.

I have no idea what the reason for that issue could be. Is it because of my code? My speaker device? Bluetooth connection? What is it?

xRay
  • 543
  • 1
  • 5
  • 29

1 Answers1

0

This may solve your issue its a bit roundabout because it creates a new MediaPlayer per loop. Not able to achieve Gapless audio looping so far on Android Its seems like this issue has been a thing for a while. If you don't want to do this you may want to explore using another library instead of MediaPlayer

avalerio
  • 2,072
  • 1
  • 12
  • 11