W/IMediaDeathNotifier:媒体服务器死了 [英] W/IMediaDeathNotifier﹕ media server died

查看:300
本文介绍了W/IMediaDeathNotifier:媒体服务器死了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Google Glass MIC录制音频,但我不断收到 W/IMediaDeathNotifier:媒体服务器死机错误.有想法吗?

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();
        }
    }

}

日志:

4242-4242/com.google.android.glass.sample.charades E/AudioRecordTest:文件名:/storage/emulated/0/audiorecordtest.3gp

4242-4255/com.google.android.glass.sample.charades W/IMediaDeathNotifier:媒体服务器死了

我还对 AndroidManifest.xml 文件添加了以下权限:

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" />

推荐答案

尝试调用setPreviewDisplay,它在任何地方都没有显示,但是有人说预览用作存储视频文件的来源.

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)

这篇关于W/IMediaDeathNotifier:媒体服务器死了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆