简体   繁体   中英

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!

是的,根据我的说法,使用两个 MediaPlayer 对象并这样做就很好,根据我的经验,声音播放或任何内存问题都没有任何问题,就像魅力一样。

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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM