开发者

Android: how to play 2 media files simultaneously in sync

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 to开发者_运维百科gether.

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!


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜