我是java的新手。我试图一个一个地播放它们,但我得到一个错误。如何将两个音频文件合并为一个?请帮帮我。如果用户键入不同的文本,它应该播放不同的声音。我知道声音开始之间应该有一些停顿,但我该怎么做。我也可以组合每个字母的所有声音,然后播放整个声音吗?
setContentView(R.layout.main);
Button bStart = (Button) findViewById(R.id.bStart);
final EditText etStart = (EditText) findViewById(R.id.etStart);
final EditText etFinish = (EditText) findViewById(R.id.etFinish);
final char[] arr = etStart.getText().toString().toCharArray();
final MediaPlayer as = MediaPlayer.create(R2d2Activity.this, R.raw.as);
final MediaPlayer bs = MediaPlayer.create(R2d2Activity.this, R.raw.bs);
final SoundPool sp;
final int a;
sp = new SoundPool(2, AudioManager.STREAM_MUSIC, 0);
a = sp.load(this, R.raw.as, 1);
bStart.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
for (int i=0; i<1; i++){
String value = etStart.getText().toString();
String first = value.substring(i, i + 1);
if(first.contentEquals("a")){
sp.play(a, 100, 100, 0, 0, 1);
}if(first.contentEquals("b")){
sp.play(b, 100, 100, 0, 0, 1);
}
}