I'm trying to record audio using the glass gdk and am finding it quite problematic.
I'm using media recorder and have all the right permissions, but I keep getting media recorder 100 errors. My code looks something like this:
mMediaRecorder = new MediaRecorder();
mMediaRecorder.setOnErrorListener(new MediaRecorder.OnErrorListener() {
public void onError(MediaRecorder mediarecorder1, int k, int i1) {
Log.e(TAG, String.format("Media Recorder error: k=%d, i1=%d", k, i1));
}
});
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.AMR_NB);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setOutputFile(mAudioFile.getAbsolutePath());
mMediaRecorder.prepare();
mMediaRecorder.start();
This has to be something to do with the Google Glass as I have run the exact same code on an android phone and it recorded audio correctly. I can find very few resources about using media recorder to only record audio on glass, most posts I have seen are people recording video and audio, whilst I am not interested in video.
Any help working out how I can recorder audio on Google Glass would be greatly appreciated!
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
I just tested this in an immersive activity targeting the latest GDK on an XE22 Glass. What I saw with your original code was a bunch of native logcat messages suggesting codec issues. This combination of codec and container does work and I was able to retrieve the audio file and play it back on my notebook.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With