我想一个接一个地播放 MediaPlayer,我可以获取第一个文件但无法获取剩余的文件...
此代码是否正确...
private void playRecording() {
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");
}else i=0;
}
});
player.start();
播放音频:
private void playAudio(String filename) {
try {
player.setDataSource(filename);
player.prepare();
player.start();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}