如何在同一时间播放多个OGG或MP3 ..? [英] How to play multiple ogg or mp3 at the same time..?
问题描述
我想打20 OGG文件在使用MediaPlayer的同一时间。 这是因为我想打一个混合效果。 当一个正在播放音乐,其他文件也有要播放。 其实,我已经做了该功能通过iOS的应用程序,它没有任何问题,打混匀。 而现在,我应该转换这个程序为Android应用程序。 所以我被判20媒体播放器变量
I'm trying to play 20 ogg files at the same time using MediaPlayer. This is because I want to make a mixing effect. While one music is playing, other files also have to be played. Actually, I already made an application with this function by iOS, and it didn't have any problems to play and mix. And now, I should convert this app into android app. so I sentenced 20 mediaplayer variables
MediaPlayer的PLAYER1;
MediaPlayer的player2;
MediaPlayer的player3;
......
MediaPlayer player1;
MediaPlayer player2;
MediaPlayer player3;
.....
play1 = (Button)findViewById(R.id.btn1);
play2 = (Button)findViewById(R.id.btn2);
play3 = (Button)findViewById(R.id.btn3);
......
play1.setOnClickListener(this);
play2.setOnClickListener(this);
play3.setOnClickListener(this);
......
每当我点击每一个按钮,它发挥各自的声音和混合。
and whenever I click each button, it play each sound and mix.
player1 = MediaPlayer.create(TestActivity.this, R.raw.md_cricket2);
player1.setLooping(true);
player1.start();
......
不过,我有一些问题,在这一点上。 两种声音的混合是好的,但是当我试图播放超过3声, 一些声音,如嘀,嘀的补充。这听起来像白噪音.. 我不知道为什么? 我认为这是非常简单的,以使机器人这个混合应用程序,因为 我已经做到了在iOS上,但我不知道是什么问题... 是否有任何人谁可以告诉我吗? 我想的Soundpool是不是答案。这只是短期的声音。 MediaPlayer的是不正确的,同时播放多个声音? 然后,我怎样才能使这个功能呢?
However, I have some problems at this point. Two sounds mixing is ok, but when I tried to play more than 3 sounds, some noises like "tick, tick" are added. It sounds like white noise.. I don't know why... I thought it is really simple to make this mixing application in android, because I already did it in iOS, but I don't know what the problem is... Is there anybody who can advise me? I think soundpool is not an answer. It is only for short sounds. MediaPlayer is not proper to play multiple sounds at the same time? Then, How can I make this function?
推荐答案
播放声音同时与多个媒体播放器不推荐(可能发生崩溃)。 你最好使用的Soundpool 。不幸的是,我没有任何与它的经验,我自己,所以我不能帮你那里,但也许这个帖子会帮助
Playing sounds simultaneously with multiple media players is not recommend (crashes may occur). You'd better use soundpool. Unfortunately, I don't have any experience with it myself so I can't help you there, but perhaps this post will help
这篇关于如何在同一时间播放多个OGG或MP3 ..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!