In my application, when i will click a button, it should open the camera flash for a long time like torch. This implementation is pretty easy in Android. But in BlackBerry i did not get any direct API for this. I have tried some sort of things by which i am able to on the Video and able to make the flash for few seconds. But if you check this app, they made it possible: Flashlight Free(in App World).
Here is my code:
if(field == btnTorch)
{
Player player;
VideoControl _videoControl;
vfmScreen.delete(btnTorch);
try {
player = Manager.createPlayer("capture://video");
player.realize();
Logger.out("Torch", "player realized");
_videoControl = (VideoControl) player.getControl("VideoControl");
FlashControl flashControl = new FlashControl()
{
public int getMode() {
// TODO Auto-generated method stub
Logger.out("Torch", "inside getmode");
return 0;
}
public int[] getSupportedModes() {
// TODO Auto-generated method stub
Logger.out("Torch", "inside getSupportedModes");
return null;
}
public boolean isFlashReady() {
// TODO Auto-generated method stub
return false;
}
public void setMode(int arg0) {
// TODO Auto-generated method stub
Logger.out("Torch", "inside setMode");
}
};
flashControl = (FlashControl) player
.getControl("javax.microedition.amms.control.camera.FlashControl");
if(flashControl!= null) {
Logger.out("Torch", "before Forced fully set the mode");
flashControl.setMode(FlashControl.FORCE);
Logger.out("Torch", "Forced fully set the mode");
}
if (_videoControl != null)
{
Field _videoField = (Field) _videoControl.initDisplayMode(
VideoControl.USE_GUI_PRIMITIVE,
"net.rim.device.api.ui.Field");
_videoControl.setVisible(true);
_videoControl.setDisplayFullScreen(true);
vfmScreen.add(_videoField);
player.start();
EnhancedFocusControl efc = (EnhancedFocusControl)player.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
efc.startAutoFocus();
Logger.out("Torch", "player started ");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (MediaException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
So what is the possible way to make it?
Thanks,
Arindam.