I have two different code bases with the same problem.
The first one is code copied straight from developer.android.com here:
http://developer.android.com/guide/topics/media/camera.html#custom-camera
The second one is this code:
http://android-er.blogspot.com.au/2011/10/simple-exercise-of-video-capture-using.html
Both work fine with the normal rear camera, but as soon as I try to use the front facing camera I get the error.
This happens on the following devices:
I have tried what looks like 2.2 era Camera Params as well, which some people claim is required with some Samsung and HTC devices, although multiple different articles reference different String Keys:
c = Camera.open(frontFacingCameraID); // attempt to get a Camera instance
Camera.Parameters params = c.getParameters();
params.set("cam-mode", 1);
params.set("cam_mode", 1);
params.set("camera-id", 1);
c.setParameters(params);
None of these work, also please note that I am detecting the correct Front Facing Camera ID which on the Nexus 7 is of course: 0. But the results are the same on all the devices.
I have tried using low quality profile, I have tried setting the video resolution, encoder, output format, bitrate, frame rate and video size manually in a multitude of ways but none which have worked.
The thing which makes me think theres nothing wrong with most of the code is that the regular camera works fine. So my guess is its something to do with the prepareVideoRecorder() / prepareMediaRecorder() method which sets up the Media Recorder.
Perhaps a Media Recorder manual encoding settings that are known to work on a front facing camera?
I have to say, the Android Camera and MediaRecorder API's suck. Compared with iOS its a bit of a mess, not to mention some of the scary looking param incompatibility issues and different resolutions across the fragmented device landscape.
Assuming I can get it working on my JB devices, does anyone know from experience if most of these issues are resolved with API 15 ICS?
I would consider not supporting API 10 Gingerbread if its going to be too hard to support.
See Question&Answers more detail:
os