Sound recording in Google Glass

I am trying to record sound using glass gdk and I find it quite problematic.

I use a media recorder and have all permissions, but I continue to receive 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 should be somehow related to Google Glass, as I run the same code on my Android phone and recorded the sound correctly. I can find very few resources related to using a media recorder, only for recording sound on glass, most of the messages that I have seen are people who record video and audio, until I am interested in video.

Any help in developing how I can record audio in Google Glass would be greatly appreciated!

+5
source share
1 answer
 mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC); 

I just tested this for exciting activity aimed at the latest version of GDK on XE22 glass. What I saw with your source code was a bunch of logcat native messages suggesting codec problems. This combination of codecs and containers really works, and I was able to get the audio file and play it on my laptop.

+2
source

Source: https://habr.com/ru/post/1205501/


All Articles