I'm trying to record audio using Google Glass MIC but I keep getting W/IMediaDeathNotifier﹕ media server died error. Thoughts?
It should start recording on the first touch and stops on the second touch, but the error happens on the first click.
package com.google.android.glass.sample.charades;
import android.media.MediaRecorder;
import java.io.IOException;
import android.util.Log;
import android.os.Environment;
public class SlideshowActivity extends Activity {
private static final String LOG_TAG = "AudioRecordTest";
private MediaRecorder mRecorder = null;
private static String mFileName = Environment.getExternalStorageDirectory().getAbsolutePath() + "/audiorecordtest.3gp";
private boolean recording = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_slideshow);
mGestureDetector = new GestureDetector(this).setBaseListener(mBaseListener);
}
private void startRecording() {
mRecorder = new MediaRecorder();
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(mFileName);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);
Log.e(LOG_TAG, "File name: " + mFileName);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(LOG_TAG, "prepare() failed");
}
mRecorder.start();
}
private void stopRecording() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
}
private void onRecord(boolean start) {
if (start) {
startRecording();
} else {
stopRecording();
}
}
}
Log:
4242-4242/com.google.android.glass.sample.charades E/AudioRecordTest﹕ File name: /storage/emulated/0/audiorecordtest.3gp
4242-4255/com.google.android.glass.sample.charades W/IMediaDeathNotifier﹕ media server died
I've also added the following permission on the AndroidManifest.xml file:
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAPTURE_AUDIO_OUTPUT" />
SurfaceHolder
and how this works. – Spiritualize