前面カメラからビデオを録画しようとしているときに、エクセレントを下回っています。ただし、背面カメラの録画は正常に機能します。クラッシュはオンラインですmMediaRecorder.start();
java.lang.RuntimeException: start failed.
at android.media.MediaRecorder.start(MediaRecorder.java)
at xyz.CameraFragment$6.onClick(CameraFragment.java:270)
at android.view.View.performClick(View.java:4466)
at android.view.View$PerformClick.run(View.java:18537)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5102)
at java.lang.reflect.Method.invokeNative(Method.java)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(NativeStart.java)
以下は私のコードです-
private boolean prepareVideoRecorder() {
mMediaRecorder = new MediaRecorder();
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mVideoFile = new File(getOutputMediaFile().toString());
mMediaRecorder.setOutputFile(mVideoFile.getAbsolutePath());
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
mMediaRecorder.setOrientationHint(270);
mMediaRecorder.setMaxDuration(10000);
mMediaRecorder.setOnInfoListener(this);
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
Log.d("CAMERA", "IllegalStateException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
} catch (IOException e) {
Log.d("CAMERA", "IOException preparing MediaRecorder: " + e.getMessage());
releaseMediaRecorder();
return false;
}
return true;
}
if (prepareVideoRecorder()) {
// Camera is available and unlocked, MediaRecorder is prepared,
// now you can start recording
mMediaRecorder.start();
}