0
我使用以下代碼播放SD卡中的音頻。但它不起作用,即使不拋出錯誤。我的文件位於以下路徑/sdcard/media/blueeye.mp3中。有什麼建議麼。播放音頻文件
public void audioPlayer(){
//set up MediaPlayer
MediaPlayer mp = new MediaPlayer();
try {
mp.setDataSource(mp.setDataSource(getExternalFilesDir() + "/media/blueeye.mp3"););
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
mp.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
mp.start();
}