2

Using the CWAC-Camera library, I have created a fragment extending the CameraFragment. I've added an OnClickListener which calls autofocus() whenever the screen is tapped. However, when I start recording a video, I would like to use some form of continuous focus. Tapping the screen while recording does not initiate an autofocus.

With the regular camera app on Android, the camera always focuses when filming. How can this be achieved with the CWAC-Camera library?

user3014924
  • 153
  • 4

1 Answers1

1

How can this be achieved with the CWAC-Camera library?

I doubt that it can, insofar as MediaRecorder does not offer any focus control that I can see. That being said, I have filed an enhancement request with myself to track your suggestion.

With the regular camera app on Android, the camera always focuses when filming.

There are dozens, perhaps hundreds, of "regular camera apps on Android", where by "regular camera app" I assume you mean "preinstalled camera app".

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • I believe the answer lies in the Camera.Parameter, which offers various options regarding the focus mode of the camera. I am unsure though if these modes are also maintained when recording. As far as I can tell though, there is no way to alter the Camera.Parameters when using the CWAC-Camera library. "Regular camera app" is indeed the pre-installed camera app which came with Cyanogenmod 11 – user3014924 Sep 03 '14 at 14:43
  • @user3014924: "I am unsure though if these modes are also maintained when recording" -- right, and that's what I need to research. FWIW, the whole `Camera.Parameters` stuff may get overhauled in 0.7.0 of the library to address some compatibility issues. ""Regular camera app" is indeed the pre-installed camera app which came with Cyanogenmod 11" -- is that Focal? I have lost track of what all happened with respect to Focal and CM. – CommonsWare Sep 03 '14 at 14:48
  • I'm afraid I cannot answer that. One more note, now you're mentioning "issues". I ran into an issue where I had been debugging all day and could not find out why I got an error something in the line like "getParameters() is emtpy (native method)". It seemed that I did have the WRITE_EXTERNAL_STORAGE permission and CAMERA permission but did not have the RECORD_AUDIO permission enabled. My point being, as a "newbie" to the camera system, I assumed the CAMERA permission would also handle audio, yet it did not. I cannot remember reading anything about permissions on your Github site, fyi. – user3014924 Sep 03 '14 at 15:00
  • @user3014924: I have added a paragraph on permissions to the project `README` -- thanks! – CommonsWare Sep 03 '14 at 15:04
  • Great! I recall reading a few bug reports where the same stacktrace was posted but wasn't solved due to the user not supplying a reproduction of the issue. I think this will solve it in some cases. Also, the error also occurs when for instance you manually modify the CamcorderProfile to an unsupported value (e.a. CamcorderProfile.videoFrameWidth = 9999999) or the CamcorderProfile is not supported on the device (e.a. CamcorderProfile.QUALITY_QVGA). Again, just fyi. I think you did a great job and am thankful you created this! – user3014924 Sep 03 '14 at 19:26