You cannot take a photo while recording a video only if the camera is locked () for recording
I am developing an application that can record video, take photos and while recording video you can take photos. For simple video recording and photography, I have no problem. The problem is when I start video recording and I try camera.takePicture(null, null, jpegCallback);
. On some devices, it never goes public void onPictureTaken(byte[] data, Camera camera){}
to mine PictureCallback jpegCallback
. I have checked for many hours and stackoverflow is my last hope to solve this problem.
At the beginning of the code in VideoRecordActivity
in, surfaceChanged()
I open and set the camera like this:
camera = Camera.open();
Camera.Parameters p = camera.getParameters();
p.setPreviewSize(camcorderProfile.videoFrameWidth, camcorderProfile.videoFrameHeight);
p.setPreviewFrameRate(camcorderProfile.videoFrameRate);
camera.setParameters(p);
camera.setPreviewDisplay(holder);
camera.startPreview();
After that, I prepare MediaRecorder
as follows (I unlock the camera here because after I finish recording, I reconnect the camera with camera.reconnect()
and call again prepareRecorder()
and I can start recording the following video):
private void prepareRecorder() {
recorder = new MediaRecorder();
camera.unlock();
recorder.setCamera(camera);
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
recorder.setProfile(camcorderProfile);
recorder.setPreviewDisplay(holder.getSurface());
}
I cannot record video if mine is camera.unlock()
not called before recorder.setCamera(camera);
. But on some devices if I try takePicture()
while recording a video and after that camera.unlock()
it never gets overridden public void onPictureTaken(byte[] data, Camera camera)
. If I just comment camera.unlock()
and never start recording video in first place, but just the tab on the visible TakePhoto button, it works and takes pictures as usual. Any ideas why I can't take photos on some devices after starting video recording and unlocking () the camera?
I tested this on Android 4.4.2 - Samsung Galaxy Tab 4 10 "and 7". At 7 "I can take photos while recording, but at 10" I can't. Any ideas? Best regards, Vlad.
source to share
No one has answered this question yet
See similar questions:
or similar: