找回我現在的儲蓄一些聲音通過媒體播放錄音:我在SD卡有一個聲音文件已經如何在Android的
private void startrecording() {
audiofile = getAudiofile();
if (audiofile != null)
myaudiorecoreder = new MediaRecorder();
myaudiorecoreder.setAudioSource(MediaRecorder.AudioSource.MIC);
myaudiorecoreder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
myaudiorecoreder.setOutputFile(audiofile.getAbsolutePath());
myaudiorecoreder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
try {
myaudiorecoreder.prepare();
setRecordstatus(true);
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
myrecordtextview.setText("RECORDING STARTED..SPEAK NOW");
myaudiorecoreder.start();
// 其中的AudioFile會給聲音文件。 這裏是我從中獲取文件(空)的getAudiofile()的代碼。 //
private File getAudiofile() {
String extState = Environment.getExternalStorageState();
if (extState.equals(Environment.MEDIA_MOUNTED)) {
File mediaStorageDir = new File(
Environment.getExternalStorageDirectory() + "/TAUKY/AUDIO");
if (!mediaStorageDir.exists()) {
if (!mediaStorageDir.mkdirs()) {
Log.e("SDCARD", "failed to create directory");
Toast.makeText(getApplicationContext(),
"FAILED TO CREATE DIR", 0).show();
return null;
}
}
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss")
.format(new Date());
mediaFile = new File(mediaStorageDir.getPath() + File.separator
+ "SOUND_" + timeStamp + ".mp3");
// Toast.makeText(getApplicationContext(), "FILE CREATION DONE",
// 0).show();
} else {
Toast.makeText(getApplicationContext(), "NO SDCARD", 0).show();
}
return mediaFile;
}
現在就下活動如何從SD卡即/ TAUKY/AUDIO的特定文件夾檢索 感謝
定義「檢索」。 –
檢索意味着從特定文件夾中提取 – blackjack