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
Android Cardview Remove Padding
Push Up Content When Clicking in Edit Text
How to Use Data Binding and Kotlin in Android Studio 3.0.0
Android - How to Set an Alarm to a Specific Date
Rendering Problems in Android Studio V 1.1/1.2
How to Open Navigation Drawer with No Actionbar, Open with Just a Button
Android 5.0: How to Change Recent Apps Title Color
Proguard Warnings "Can't Write Resource [Meta-Inf/Manifest.Mf] (Duplicate Zip Entry)"
Android UI Design: Supporting Multiple Screens
How to Use Getlistview() in Activity
Event for Videoview Playback State or Mediacontroller Play/Pause
Android Notification with Buttons on It
Errors Managing the Unityplayer Lifecycle in a Native Android Application
Updated Sdk Version, Getting Classnotfoundexception: Android.Support.V4.View.Viewpager
Change Device Language via Adb
Android Sdk Content Loader Failing with Nullpointerexception