gpt4 book ai didi

audio - W/IMediaDeathNotifier:媒体服务器死了

转载 作者:行者123 更新时间:2023-12-02 22:45:53 45 4
gpt4 key购买 nike

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

它应该在第一次触摸时开始记录,而在第二次触摸时停止,但是在第一次单击时发生错误。

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 文件添加了以下权限:
<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,它在任何地方都没有记录,但是有人说预览用作存储视频文件的源。

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

关于audio - W/IMediaDeathNotifier:媒体服务器死了,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24823019/

45 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com