My question is: How can I programmatically set the AudioEncoder for MediaRecorder?
I am trying to programmatically set the AudioEncoder by replacing the statically set AAC or AAC_ELD with the int variable mEncode which is manually selected from a list of variables such as:
int mEncode = 3; OR int mEncode = 5;
When I replace AAC with int variable mEncode with value of 3 or 5 the code will not compile. I get error message Cannot resolve symbol 'mEncode".
Android documentation shows that: int AAC Constant Value: 3 (0x00000003) int AAC_ELD Constant Value: 5 (0x00000005) https://developer.android.com/reference/android/media/MediaRecorder.AudioEncoder.html
Can anyone help me with the correct code?
Java code:
mRecorder = new MediaRecorder();
mRecorder.setAudioSamplingRate(16000);
mRecorder.setAudioEncodingBitRate(24000);
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// my current static method set with AAC or AAC_ELD:
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mRecorder.setOutputFile(mFileName);
// my dynamic method set with int variable mEncode:
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.mEncode);
User contributions licensed under CC BY-SA 3.0