Reputation: 123
I'm trying to play 2 audio files (in this case mp3) simultaneously, so that they start at EXACTLY the same time and play in sync with each other.
My first try was to just use two MediaPlayers, prepare them ahead of time, then call start on each one back to back:
mediaPlayer.start();
secondPlayer.start();
Unfortunately, that only works some of the time. Sometimes they start together, and then will stay in sync. Sometimes, there is a very small time gap between when they start, so that they will not be in sync together.
Is there a better technique for playing audio files to ensure that they start simultaneously? I need to be able to control their volumes independently as well.
Thanks!
Upvotes: 3
Views: 4254
Reputation: 364
try SoundPool,its a better method of dealing with multiple audio files at the same time.
Heres the documentation:
http://developer.android.com/reference/android/media/SoundPool.html
Hope this helps
Upvotes: 2