Android的:如何在同步同时播放2媒体文件 [英] Android: how to play 2 media files simultaneously in sync

查看:168
本文介绍了Android的:如何在同步同时播放2媒体文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图同时播放2个音频文件(在这种情况下,MP3),这样,他们开始在完全相同的时间和同步与对方玩了。

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.

我的第一次尝试是只使用两个MediaPlayers,prepare他们的时间提前,然后调用开始每一个背靠背的:

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.

谢谢!

推荐答案

尝试的Soundpool,其与多个音频文件处理的同时更好的方法。

try SoundPool,its a better method of dealing with multiple audio files at the same time.

继承人的文档:

http://developer.android.com/reference/android/media/ SoundPool.html

希望这有助于

这篇关于Android的:如何在同步同时播放2媒体文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆