我正在尝试捕获视频,但执行到recorder.prepare()语句时程序抛出异常:
private void recordVideoStart(){
if(recorder != null)
{
recorder.stop();
recorder.release();
}
File file = new File("/sdcard/videoTest.3gpp");
try {
file.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
recorder = new MediaRecorder();
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setOutputFile(file.getAbsolutePath());
recorder.setVideoSize(176, 144);
recorder.setVideoFrameRate(15);
//recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setPreviewDisplay(videoPreview.getSurface());
try {
recorder.prepare();
} catch (IllegalStateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
recorder.start();
}
查看LogCat,我注意到了这一行“相机不可用”。
有人知道这里可能出了什么问题,以及如何启用视频捕捉吗?
谢谢!