E / MediaRecorder:输出文件已设置

时间:2018-09-16 17:21:40

标签: android android-mediarecorder

我试图用MediaRecorder录制音频,但出现以下错误:

  

W / System.err:在com.smarthear.audiodetection.SoundDetectionService.detectSound(SoundDetectionService.java:56)                     在com.smarthear.audiodetection.SoundDetectionService.onStartCommand(SoundDetectionService.java:37)                     在android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3072)                     在android.app.ActivityThread.access $ 2100(ActivityThread.java:144)                     在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1470)                     在android.os.Handler.dispatchMessage(Handler.java:102)                     在android.os.Looper.loop(Looper.java:155)                     在android.app.ActivityThread.main(ActivityThread.java:5696)                     在java.lang.reflect.Method.invoke(本机方法)                     在java.lang.reflect.Method.invoke(Method.java:372)                     在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1029)                     在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)   E / MediaRecorder:输出文件已设置

这是我的代码

if(mRecorder==null) {
            mRecorder = new MediaRecorder();
            mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
            mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
            mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);

        }
       do {
            try {
               mRecorder.setOutputFile("/dev/null");
                mRecorder.prepare();
                mRecorder.getMaxAmplitude();
                mRecorder.start();
            }

还设置了所有必要的用户权限。

谢谢

0 个答案:

没有答案