Reputation: 2352
In my app, I have to play many sounds (mp3 files downloaded and stored on SD Card) one after the other. So I used a basic MediaPlayer and I set setOnCompletionListener method to continue playing next media file:
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
mediaPlayer.setDataSource(PATH + Constants.Medias.PATH + SLASH + (pref + 1) + SLASH + AppUtils.format(suffix + 1) + AppUtils.format(currentMediaFile));
My big problem is that there is GAP when switching from a file to the next one... It make a strange noise that disturbs users. Have you any idea how to play these files as if they are "one track" (continuously).
Upvotes: 2
Views: 1421
Reputation: 13548
You can try to create two instances of MediaPlayer
(let's call them M1 and M2).
prepare()
is called)OnCompletionListener
triggers M2 which starts to playIf this doesn't work and you still hear noise try to use SoundPool instead of MediaPlayer
.
Upvotes: 3