private void startRecording() {
File sampleDir = Environment.getExternalStorageDirectory();
if (mAudiofile == null) {
try {
//mAudiofile = File.createTempFile("sound1", ".amr", sampleDir);
mAudiofile = File.createTempFile("sound1", ".amr");
mAudiofile.deleteOnExit();
} catch (IOException e) {
Log.e("Sound Recording", "sdcard access error");
return;
}
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(mAudiofile.getAbsolutePath());
Log.e("Absolute path", "path "+mAudiofile.getAbsolutePath());
try {
mRecorder.prepare();
mRecorder.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public void stopRecordingAndPlay() {
mMode=ERecordingState.EStatePlayingAudio;
if(mSoundPool != null)
{
try
{
mSoundPool.unload(mSoundId);
}
catch(Exception e)
{
}
}
mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mRecorder.stop();
mRecorder.release();
mRecorder=null;
Log.w("Inside", "here3");
mSoundId = 0;
mSoundId = mSoundPool.load(mAudiofileForRecord.getAbsolutePath(), 0);
mSoundPool.setOnLoadCompleteListener(this);
}
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
// TODO Auto-generated method stub
if(mMode!=ERecordingState.EStateIdle)
mSoundPool.play(mSoundId, 1, 1, 0, 0, PITCH);
}
File sampleDir = Environment.getExternalStorageDirectory();
if (mAudiofile == null) {
try {
//mAudiofile = File.createTempFile("sound1", ".amr", sampleDir);
mAudiofile = File.createTempFile("sound1", ".amr");
mAudiofile.deleteOnExit();
} catch (IOException e) {
Log.e("Sound Recording", "sdcard access error");
return;
}
}
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mRecorder.setOutputFile(mAudiofile.getAbsolutePath());
Log.e("Absolute path", "path "+mAudiofile.getAbsolutePath());
try {
mRecorder.prepare();
mRecorder.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public void stopRecordingAndPlay() {
mMode=ERecordingState.EStatePlayingAudio;
if(mSoundPool != null)
{
try
{
mSoundPool.unload(mSoundId);
}
catch(Exception e)
{
}
}
mSoundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
mRecorder.stop();
mRecorder.release();
mRecorder=null;
Log.w("Inside", "here3");
mSoundId = 0;
mSoundId = mSoundPool.load(mAudiofileForRecord.getAbsolutePath(), 0);
mSoundPool.setOnLoadCompleteListener(this);
}
@Override
public void onLoadComplete(SoundPool soundPool, int sampleId, int status) {
// TODO Auto-generated method stub
if(mMode!=ERecordingState.EStateIdle)
mSoundPool.play(mSoundId, 1, 1, 0, 0, PITCH);
}
No comments:
Post a Comment