W/IMediaDeathNotifier﹕ media server died
Asked Answered
S

2

1

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" />
Spiritualize answered 18/7, 2014 at 10:36 Comment(0)
B
5

Try calling setPreviewDisplay, it isn't noted anywhere but some people say the preview is used as source to store the video file.

http://developer.android.com/reference/android/media/MediaRecorder.html#setPreviewDisplay(android.view.Surface)

Bilabial answered 18/7, 2014 at 13:15 Comment(2)
Thanks! That seems to work. Struggling now with the SurfaceHolder and how this works.Spiritualize
Well marking it as an answer would be great for my fake internet points and ego, thanks! ;)Bilabial
R
0

I similar this on audio record.

Fix: change format recorder

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.AAC_ADTS);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

Change example:

mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
Ringed answered 27/12, 2017 at 12:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.