任何人都向我解释了如何在 android 程序中使用 OnCompletionListener 一个接一个地播放音频...这里无法获取第二个音频文件..
private void playRecording() throws IllegalArgumentException,
SecurityException, IllegalStateException, IOException {
player = new MediaPlayer();
player.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
// TODO Auto-generated method stub
player.stop();
if (i < numberOfFiles) {
i++;
playAudio(Environment.getExternalStorageDirectory()
.getAbsolutePath() + "/android" + i + ".3gp");
}
}
});
player.start();
}
private void playAudio(String filename) {
try {
Toast.makeText(getApplicationContext(), filename, Toast.LENGTH_LONG)
.show();
player.setDataSource(filename);
player.prepare();
player.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}