在我的应用程序中,当我单击一个按钮时,它应该像手电筒一样长时间打开相机闪光灯。这个实现在 Android 中非常简单。但是在黑莓中,我没有得到任何直接的 API。我已经尝试了一些东西,我可以通过这些东西在视频上制作闪光灯几秒钟。但是,如果您检查这个应用程序,他们就可以做到:手电筒免费(在应用程序世界中)。
这是我的代码:
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();
}
}
那么有什么可能的方法呢?
谢谢,
阿林丹。