I'm currently recording audio with the following code:
recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
audio_path = getFilename();
recorder.setOutputFile(audio_path);
recorder.prepare();
recorder.start();
It is working, and I can record an audio with the mime type
audio/mpeg. But when I send this audio file to server or to an IOS device then they are not able to play this audio. It is working on other android devices. On FireFox it shows error message that No video with supported format or mime type found
and on chrome it does also not work.
I tried to change the mime type with following code, which I found on
This Link:
mRecorder.stop();
mRecorder.release();
String[] paths = {mFileName};
String[] mimeTypes = {"audio/mp3"};
MediaScannerConnection.scanFile(getApplicationContext(),
paths,
mimeTypes,
new MediaScannerConnection.OnScanCompletedListener() {
@Override
public void onScanCompleted(String path, Uri uri) {
System.out.println("SCAN COMPLETED: " + path);
}
});
But it is also not changing the mime type of the audio file. How I can set the mime type
audio/mp3?
AAC format worked in both iOS and Android set MediaRecorder Encoder to AAC
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
Check the below link there is multiple answer