Here is my problem : I would like to create a specific component with the camera and an image representing a target overlaying the VideoControl's view.
First I would like to display the camera in a MainScreen with a TitleBar.
Here is my code :
public class ScanScreen extends MainScreen {
private ScanScreen()
{
super();
this.vfm = new VerticalFieldManager(Field.FIELD_VCENTER);
this.controller = new ScanController(this);
//Initialize the player.
try
{
this.player = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
this.player.realize();
this.player.prefetch();
this.videoControl = (VideoControl) this.player.getControl("VideoControl");
if(this.videoControl != null)
{
// Initialize the field where the content of the camera shall be displayed.
Field videoField = (Field) this.videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
// Display the video control.
this.videoControl.setDisplayFullScreen(true);
this.videoControl.setVisible(true);
// Start the player.
this.player.start();
// Add the video field to the main screen.
if(videoField != null)
{
this.vfm.add(videoField);
}
else
{
LabelField sorry = new LabelField("Sorry, we cannot use camera right now.");
this.vfm.add(sorry);
}
}
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
// TODO : the camera is hiding the title bar
this.setTitle("Title");
this.add(this.vfm);
}
}
The first problem is that the view of the VideoContol is hiding my title bar. How can I fix that ?
The second thing : I have a specific rectangular image representing a target with transparency which I would like to displaying over the view of the VideoControl.
I first tried to create a new class extending Field returning the dimensions of this image and make the image displayed in the paint method (this class is "mypackage.CameraField"). Then I tried to instantiate my VideoField with the name of my new class "mypackage.CameraField" in the initDisplayMode ; but the created videoField is null.
So, is there a solution to create that kind of behaviour ? I am thinking about the native application "Video Camera" in the "Multimedia" folder that displays a VideoControl in a specific area of the screen.
Thank you.
Ok, it seems that is not possible to customize the VideoControl in any way. We must use it in fullscreen and cannot display anything on it.