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
Accepted Solution

How to customize the camera display

Hello everybody.

 

I am using the camera in my application. I used this code to get the camera displayed in my application :

 

 

        /**
	 * Instance of {@see javax.microedition.media.Player} used to manage medias. 
	 */
	private Player player;

	/**
	 * The video control..
	 */
	private VideoControl videoControl;
	
	/**
	 * The vertical layout used to display the camera
	 */
	private VerticalFieldManager vfm = new VerticalFieldManager(Field.FIELD_VCENTER);

	/**
	 * Default constructor.
	 */
	public ScanScreen() 
	{
		super(NO_VERTICAL_SCROLL);
		
		//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)
        {
        }
            this.add(this.vfm);
	}

 

 

The fact is that the camera covered the whole screen ; because of setFullScreen(true)? But if I remove it, and use setDisplayPosition and setDisplaySize, nothing is displayed.

 

So, how can I do to make the camera displayed in a given part of the screen (for example a centered 240x320 window), and to display some specific buttons in the upper part of the screen ?

 

Thanks in advance.

Developer
Posts: 604
Registered: ‎12-27-2010
My Device: Not Specified

Re: How to customize the camera display

As a heads up, the viewfinder does not allow third-parties to display anything over top of it. In my experience (though I may have been doing something wrong) I was only able to get two sizes out of the viewfinder, fullscreen and one about half the screen. If you send it odd dimensions it will just not display itself at all, even if it seems like you should be passing it legitimate parameters.

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

Re: How to customize the camera display

Ok, I was afraid about that. It seems that  you confirmed it, thank you.

This is very boring.

 

I cannot understand why things like that are not possible, it is very frustrating, the creativity is very limited. Rim must do a big effort to create a more efficient sdk and allow the developers to make apps that do not suck. Maybe it is the time to drop j2me...

Developer
Posts: 207
Registered: ‎09-10-2010
My Device: Not Specified

Re: How to customize the camera display

yes it's not possible. Check out the official response from RIM.