Android:Record Sound in Mp3 Format

Android:How To Get Media Recorder Output In MP3 Format?

There's currently no MP3 encoder built into the Android framework (as far as I know), so you can't do it out of the box. You need to add an MP3 encoding library to your project to do so.

For this, you can look at this stackoverflow post for a complete answer.

recordAudio in mp3 format using MIC in android

public void recordAudio(String fileName) {
final MediaRecorder recorder = new MediaRecorder();
ContentValues values = new ContentValues(3);
values.put(MediaStore.MediaColumns.TITLE, fileName);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
recorder.setOutputFile("/sdcard/sound/" + fileName);
try {
recorder.prepare();
} catch (Exception e){
e.printStackTrace();
}

final ProgressDialog mProgressDialog = new ProgressDialog(MyActivity.this);
mProgressDialog.setTitle(R.string.lbl_recording);
mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
mProgressDialog.setButton("Stop recording", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
mProgressDialog.dismiss();
recorder.stop();
recorder.release();
}
});

mProgressDialog.setOnCancelListener(new DialogInterface.OnCancelListener(){
public void onCancel(DialogInterface p1) {
recorder.stop();
recorder.release();
}
});
recorder.start();
mProgressDialog.show();
}

Android: How to record mp3 radio (audio) stream

Maybe you should read audio stream "byte by byte" and then place it into new file? Like a simple file copy operation, using inputstream-outputstream.



Related Topics



Leave a reply



Submit