Han Tran
Han Tran

Reputation: 2093

Play two mp3 song at the same time

I want to play two song (mp3) at the same time (one is karaoke file and one is the record audio by user). Can I use the MediaPlayer to do this? If so, is that right if I create 2 object of MediaPlayer and setDataSource for two file and play it?

Thanks!

Upvotes: 1

Views: 3785

Answers (2)

Androidcoder
Androidcoder

Reputation: 4679

When I dropped SoundPool from my game I created about 40 MediaPlayer instances for sound effects with permanent small sources, besides a background instance where a large source would change depending on the character's game area. Never had any issues with simultaneous play.

If you're going to stop a sound mid-play, be sure to use pause() instead of stop() or the instance won't play again without re-creation (an odd implementation choice IMHO):

campfire_mp.pause();
campfire_mp.seekTo(0);

Upvotes: 0

MKJParekh
MKJParekh

Reputation: 34291

Yes, According to me that's all fine using two MediaPlayer objects and do that, In my experience of doing same there has been no any problems for sound play or any memory issues,that work like charm.

Upvotes: 1

Related Questions