问题
I want to write an application like a Flashlight (with the help of the camera LED).
Player player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=video/3gpp");
player.realize();
VideoControl videoControl = (VideoControl) player.getControl("VideoControl");
if(videoControl != null)
{
videoField = (Field)videoControl.initDisplayMode( VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field" );
try
{
videoControl.setDisplaySize(1, 1);
}
catch(Exception e)
{
PGLogUtil.logString(e.toString());
}
videoControl.setVisible(true);
add(videoField);
FlashControl flashControl = (FlashControl)
player.getControl("javax.microedition.amms.control.camera.FlashControl");
setFlashlight(true);
}
player.start();
The code above works perfectly, but I want to hide the videoField
. When I removed add(videoField)
or use videoControl.setVisible(false)
, the flashlight does not work. Can someone explain why?
How I can turn lights on with a hidden videoField
?
回答1:
I just got a bb that had a flash i wanted to try my hands on this same issue. I finally got it to work anyway. On thing i observed during the whole testing time was that if the videoField is hidden like you said, the flash wouldn't work...So the trick i did was
<pre>
_videoControl.setDisplaySize( 1 , 1 );
</pre>
And that did the job for me. You could as well set it to
<pre>
_videoControl.setDisplaySize( 0 , 0 );
</pre>
But whatever you do ... ensure you set
<pre>
_videoControl.setVisible(true);
</pre>
else your flash will not work
来源:https://stackoverflow.com/questions/15153935/blackberry-possible-to-hide-video-field