I am trying to record audio in android using media recorder . it work fines for 3gp audios, but when i try the same code with aac format it fails . (here's my code for aac format):
final String outputFile = Environment.getExternalStorageDirectory().getAbsolutePath() + "/recording.acc";
final MediaRecorder myAudioRecorder = new MediaRecorder();
myAudioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
myAudioRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
myAudioRecorder.setAudioEncoder(MediaRecorder.OutputFormat.AAC_ADTS);
myAudioRecorder.setOutputFile(outputFile);
MediaPlayer mediaPlayer = new MediaPlayer();
mediaPlayer.setDataSource(outputFile);
mediaPlayer.prepare();
mediaPlayer.start();
I have added the permissions and i am triggering these functions properly using buttons. I wrote only the main code here just to make it simple My question:
What is the correct way to record and play sound in aac format ?
What is the best format to record and play audio in android using media recorder and media player and how do i implement it? I tried using 3gp but it gives low quality of sound .