Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recording Audio on Google Glass

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!

like image 949
WillEllis Avatar asked Oct 31 '22 15:10

WillEllis


1 Answers

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.

like image 67
Jeffrey Mixon Avatar answered Nov 08 '22 04:11

Jeffrey Mixon