Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Contributor
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr

How to create a custom field containing a VideoControl and an image ?

Hello everybody.

 

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.

 

Something else : 

 

I try to set the dimension of the videoControl with the 

videoControl.setDisplaySize(width, height)

 

I try different dimensions and it appears that if I set 150x150, I have a small windows displaying the videoControl that does not hide my title bar. If I set any other dimension nothing is displayed, it is like the videoControl does not exist.

 

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.

 

 

 

 

 

Contributor
Posts: 30
Registered: ‎03-24-2011
My Device: 9800
My Carrier: sfr

Re: How to create a custom field containing a VideoControl and an image ?

this.videoControl.setDisplayFullScreen(true);

If I use false instead of true, nothing is displayed in the screen.

If I use setDisplaySize with values other than 150x150, nothing is displayed. 

 

Is there any way to make the camera displayed in a specified region of the screen ?

If no why these methods setDisplayFullScreen, setDisplayLocation and setDisplaySize ?