08-23-2012 01:40 PM - edited 08-23-2012 02:49 PM
Hi,
I am developing an app that uses the camera on a Torch 9810 using SDK 7.1. I am attempting to use the
EnhancedFocusControl to set and lock the focus. My code is below:
public CameraImageCapture()
{
try
{
_camera = javax.microedition.media.Manager.createPlayer("cap ture://video?encoding=jpeg&width=1024&height=768") ;
_camera.realize();
_cameracontrol = (VideoControl) _camera.getControl("VideoControl");
if (_cameracontrol != null)
{
Field videoField = (Field) _cameracontrol.initDisplayMode(VideoControl.USE_GU I_PRIMITIVE, "net.rim.device.api.ui.Field");
_cameracontrol.setDisplayFullScreen(true);
_cameracontrol.setVisible(true);
_camera.start();
_efc = (EnhancedFocusControl) _camera.getControl("net.rim.device.api.amms.contro l.camera.EnhancedFocusControl");
if (_efc != null)
{
if (_efc.isFocusModeSupported(EnhancedFocusControl.FO CUS_MODE_CONTINUOUS)) {
_efc.setFocusMode(EnhancedFocusControl.FOCUS_MODE_ CONTINUOUS);
}
try
{
_efc.startAutoFocus();
}
catch (Exception e1)
{
Dialog.alert(e1.toString());
}
}
if(videoField != null)
{
add(videoField);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
}
When I attempt to call EnhancedFocusControl.startAutoFocus I get the following error:
javax.microedition.media.MediaException: Unable to lock focus. I have noticed few others have had this problem using the sample program but have not received an answer. Is there a solution for this problem?
Solved! Go to Solution.
08-23-2012 03:42 PM
I found that if I moved the EnhancedFocus control into the invokeAction function it was able to set the focus.