问题描述
(Camera.start prevew())。现在的问题是,如果我做出previewFrame使用MediaRecorder录像不会被调用了。
when using the Camera.PreviewCallback implementation the onPreviewFrame is called without problem after initializing camera and starting preview (Camera.startPrevew()). The problem is if I make a video recording using MediaRecorder onPreviewFrame does not get called any more.
据我所知,使用MediaRecorder录制视频时停止摄像机。previewCallback,但为什么不能重新开始?
I understand that when using MediaRecorder to record video stops the Camera.PreviewCallback, but why can't it be restarted?
我曾尝试复位相机preVIEW回调(套previewCallback(回调))并重新启动启动preVIEW,但同时我有一个preVIEW有没有通话previewFrame。
I have tried resetting the camera preview callback (setPreviewCallback(callback)) and restarting startPreview, but while I have a preview there is no call to onPreviewFrame.
推荐答案
您一定要调用surfaceChanged方法设置previewCallback,不仅在surfaceCreated。
You must to call setPreviewCallback in surfaceChanged method, not only in surfaceCreated.
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
if (mHolder.getSurface() == null){
return;
}
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
try {
mCamera.setPreviewCallback(this);
mCamera.setPreviewDisplay(mHolder);
mCamera.startPreview();
} catch (Exception e){
Log.d(TAG, "Error starting camera preview: " + e.getMessage());
}
}
这篇关于在previewFrame相机不叫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!