I need help with playing multiple audio tracks at the same time in Android
.
I am supposed to play three audio tracks at the exact same
Well, I believe I found what I could name "a temporary solution".
MediaPlayer track1 = MediaPlayer.create(this, R.raw.track1);
track1.start();
MediaPlayer track2 = MediaPlayer.create(this, R.raw.track2);
track2.start();
MediaPlayer track3 = MediaPlayer.create(this, R.raw.track3);
track3.start();
The problem with this is that the create()
method creates a noticeable gap when the songs are being played.
So this is not it.
After a while, I tried the following :
MediaPlayer track1 = MediaPlayer.create(this, R.raw.track1);
track1.start();
track1.pause();
MediaPlayer track2 = MediaPlayer.create(this, R.raw.track2);
track2.start();
track2.pause();
MediaPlayer track3 = MediaPlayer.create(this, R.raw.track3);
track3.start();
track3.pause();
// resuming...
track1.start();
track2.start();
track3.start();
That whay, the songs are more synchronous. I can still hear a very small gap but it is way better. I found this solution quite strange as well as ugly.
Unless someone has another idea, I will stick with that solution.