If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
Developer
Jam321
Posts: 59
Registered: ‎06-15-2012
My Device: 9800
My Carrier: XZY

Issue With PictureDemo

 

Hi,

           Good Afternoon every one . today i started to learn picture demo .but i am getting following error

 ERRO: javax.microedition.media.MediaException: Unable to lock focus

 

 

package mypackage;
import net.rim.device.api.ui.*;


public class ImageCaptureDemo extends UiApplication
{
public static void main(String[] args)
{
ImageCaptureDemo app = new ImageCaptureDemo();
app.enterEventDispatcher();
}

public ImageCaptureDemo()
{
pushScreen(new ImageCaptureDemoScreen());
}

}

 

=========================================

package mypackage;

import javax.microedition.media.Player;
import javax.microedition.media.control.VideoControl;

import net.rim.device.api.amms.control.camera.EnhancedFocusControl;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.container.MainScreen;

class ImageCaptureDemoScreen extends MainScreen
{
Player _p;
VideoControl _videoControl;

public ImageCaptureDemoScreen()
{
try
{
_p = javax.microedition.media.Manager.createPlayer("capture://video?encoding=jpeg&width=1024&height=768");
System.out.println("Camera initialized");
_p.realize();
System.out.println("Getting Accessing Controll");
_videoControl = (VideoControl) _p.getControl("VideoControl");
System.out.println("We get Video Controll");

if (_videoControl != null)
{
System.out.println("Video Controol is not null");
Field videoField = (Field) _videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
System.out.println("We are getting full screen");
_videoControl.setDisplayFullScreen(true);
System.out.println("Set The FullDisplay Screen");
_videoControl.setVisible(true);
System.out.println("make it Done");
_p.start();
System.out.println("Start the lunching the camera");

EnhancedFocusControl efc = (EnhancedFocusControl)_p.getControl("net.rim.device.api.amms.control.camera.EnhancedFocusControl");
efc.startAutoFocus();
System.out.println("Start the autofocus");

if(videoField != null)
{
System.out.println("VideoField Is Not Null");
add(videoField);
}
}
}
catch(Exception e)
{
System.out.println("Error Found"+e);
}
}

protected boolean invokeAction(int action)
{
boolean handled = super.invokeAction(action);

if(!handled)
{
if(action == ACTION_INVOKE)
{
try
{
byte[] rawImage = _videoControl.getSnapshot(null);
}
catch(Exception e)
{
Dialog.alert(e.toString());
}
}
}
return handled;
}
}

 

Need your Your  i am new to this forum as well as blackberry to.

Please use plain text.
Administrator
MSohm
Posts: 14,362
Registered: ‎07-09-2008
My Device: BlackBerry Z30, BlackBerry PlayBook
My Carrier: Bell

Re: Issue With PictureDemo

Which BlackBerry Smartphone model and BlackBerry handheld software version are you testing on?  You can find this under Options, About on the BlackBerry Smartphone.

 

What version of BlackBerry Java SDK are you using?

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Please use plain text.
Developer
Jam321
Posts: 59
Registered: ‎06-15-2012
My Device: 9800
My Carrier: XZY

Re: Issue With PictureDemo

i am using  6.0

Please use plain text.