Reputation: 1478
i´ve implemented the sample Code direct from Google using MediaRecorder
Also I have added some properties and set the filetype to ".mp3" (I know that it doesnt create a real mp3, but ".3gp" doesnt make sence to me either, I´m recording Audio not Video..)
Now my Problem is that, if I want to Play the file, it does nothing (0:00 sec). I checked the properties on the file, it fills up space on the storage.
ADDITIONAL:
Anyway I want to implement a visual Feedback while recording. Horizon seems to be the only good looking lib. But using Horizon you have to feed it with the buffer from Audiorecorder, which is not possible with MediaRecoder. Does anybody know a good looking lib that visualizes currently recording audio with MediaRecorder?
Thank you very much
private void startRecording() {
if(this.mRecorder != null)
return;
String fileToWrite = this.ProjectDirPath + File.separator + GetToday() + this.fileTpye;
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mRecorder.setOutputFile(fileToWrite);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
mRecorder.setAudioSamplingRate(16000);
mRecorder.setAudioEncodingBitRate(44100);
mRecorder.setAudioChannels(1);
try {
mRecorder.prepare();
}catch (IOException e) {
Log.e("startRecording()", "prepare() failed");
}
initRecorder();
mRecorder.start();
isRecording = true;
}
private void stopRecording() {
if(this.mRecorder == null)
return;
else{
try{
mRecorder.stop();
mRecorder.release();
mRecorder = null;
isRecording = false;
this.updateListView();
} catch(Exception e){
mRecorder = null;
isRecording = false;
}
}
}
public static String GetToday(){
Date presentTime_Date = Calendar.getInstance().getTime();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
return dateFormat.format(presentTime_Date);
}
Permissions are set in the manifest and at runtime.
Upvotes: 2
Views: 158