我正在开发Android自定义相机应用并试图在其中实现录像机功能。我正在使用以下代码
private boolean prepareMediaRecorder()
{
myCamera = getCameraInstance();
mediaRecorder = new MediaRecorder();
myCamera.unlock();
mediaRecorder.setCamera(myCamera);
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mediaRecorder.setPreviewDisplay(myCameraSurfaceView.getHolder().getSurface());
try
{
File newFile = File.createTempFile("videocapture", ".mp4", Environment.getExternalStorageDirectory());
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
mediaRecorder.setOutputFile(newFile.getAbsolutePath());
}
catch (IOException e)
{
e.printStackTrace();
finish();
}
try
{
mediaRecorder.prepare();
}
catch (IllegalStateException e)
{
releaseMediaRecorder();
return false;
}
catch (IOException e)
{
releaseMediaRecorder();
return false;
}
return true;
}
但是如果我使用相同的代码并在Galaxy选项卡上运行它,我会在代码的这个位置关闭一个力
mediaRecorder.start();
错误日志如下所示。
http://textuploader.com/?p=6&id=ngcFk
当我改变
时,代码工作正常 mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
到
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
不明白为什么会如此。请帮忙!谢谢!