[英]Android Force Close issue of Video Recorder implementation in Custom Camera app
I am developing an Android Custom Camera app and trying to implement the video recorder feature in it. 我正在开发一个Android Custom Camera应用程序,并尝试在其中实现视频记录器功能。 And I am using the below code
我正在使用下面的代码
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;
}
But if i use the same code and run it on Galaxy tab, i get a force close at this location of code 但是,如果我使用相同的代码并在“ Galaxy”选项卡上运行它,则会在此代码位置强制关闭
mediaRecorder.start();
And the error log looks like this. 错误日志如下所示。
http://textuploader.com/?p=6&id=ngcFk http://textuploader.com/?p=6&id=ngcFk
The code works just fine on the same, when i change 当我更改时,代码在相同的地方工作正常
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
to 至
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW));
Not getting why is it so. 不明白为什么会这样。 Please Help!
请帮忙! Thanks!
谢谢!
You should check whether the profile exists. 您应该检查配置文件是否存在。 I think for tab it is not supported.
我认为不支持选项卡。 You can try that with hasprofile
您可以尝试使用hasprofile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.