问题
I am trying to program a sound app where on button click I would like to play 3-4 sound files one after the other. How can this be done? Also I would like to increase the time of play of the files. Is this where the loop variable in play function used??
Here is part of code I have done with SoundPool. However the files all play simultaneously :(
public void onClick(View v){
//check for scan button
if(v.getId()==R.id.playbutton){
queueSound(1000);
sound.changePitchfile3(R.raw.a0);
queueSound(5000);
sound.changePitchfile2(R.raw.a1);
queueSound(10000);
sound.changePitchfile3(R.raw.a3);
}
}
});
}
private void queueSound(final long delay) {
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
}}, delay);
public void changePitchfile1(int res1) {
int soundId = (Integer) mSounds.get(res1);
this.myPlayer.play(soundId, 1, 1, 0, 0,1.125f);
}
来源:https://stackoverflow.com/questions/17687314/play-sound-file-with-a-delay-and-adjust-time-in-android