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
slaphead400
Posts: 42
Registered: ‎05-17-2011
My Device: all

getSnapShot not supported

Hi. Using bold 9700 emulator under v5 of the SDK and everytime I try to take a photo it bombs out with the getSnapShot not Supported message. I know it is because I can run the BB camerademo app without issues. However I had to tailor it to my own requirements and something must have stuffed up somewhere. This is the code I am using to set the getSnapShot which is where its failing. The full class is listed underneath in case its an issue in passing the snapshot across to a 2nd screen. Can someone please help me understand why this is failing and what to do to get it to work pls...Thanks for any assistance...

 

 public void takePicture()
    {
        try
        {
            String encoding = "encoding=jpeg&width=640&height=480&quality=normal";
            createImageScreen(videoControl.getSnapshot( encoding ));

 

            // I have also tried ---- String encoding = "encoding=jpeg&width=640&height=480&quality=normal";
            // final byte[] imagebytes = videoControl.getSnapshot( encoding );
            // createImageScreen(imagebytes);

            // still get the same issue either way.....
        }
        catch(Exception e)
        {
            UiApplication.getUiApplication().pushModalScreen(new CustomDialog("ERROR "  + e.getClass() + ":  " + e.getMessage())); 
        } 
    } //ends takePicture

 

 

 

the full class code starts here...

 

public SnapShot() { 
  
    initializeCamera();
     if(videoField != null)
        {
            createUI();
        }
        // If not, display an error message to the user
        else
        {
            UiApplication.getUiApplication().pushModalScreen(new CustomDialog("An error occurred connecting to the camera."));
        }
  
  
    } //ends SnapShot constructor
   
     private void initializeCamera()
    {
        try
        {
            // Create a player for the Blackberry's camera
            Player player = Manager.createPlayer( "capture://video?encoding=video/3gpp" );

            // Set the player to the REALIZED state (see Player javadoc)
            player.realize();

            // Grab the video control and set it to the current display
            videoControl = (VideoControl)player.getControl( "VideoControl" );

            if (videoControl != null)
            {
                // Create the video field as a GUI primitive (as opposed to a
                // direct video, which can only be used on platforms with
                // LCDUI support.)
                videoField = (Field) videoControl.initDisplayMode (VideoControl.USE_GUI_PRIMITIVE, "net.rim.device.api.ui.Field");
                videoControl.setDisplayFullScreen(false);
                videoControl.setVisible(true);
            }

            // Set the player to the STARTED state (see Player javadoc)
            player.start();
        }
        catch(Exception e)
        {
            UiApplication.getUiApplication().pushModalScreen(new CustomDialog("ERROR "  + e.getClass() + ":  " + e.getMessage()));
        }
    } //ends initializeCamera
     
       
      private void createUI()
        {
                              
        add(videoField);
               
    } //ends createUI
   
      protected boolean onSavePrompt()
    {
        return true;
    }
   
    protected boolean invokeAction(int action)
    {
        boolean handled = super.invokeAction(action);
       
        if(!handled)
        {
            switch(action)
            {
                case ACTION_INVOKE: // Trackball click
                {   
                    takePicture();
                    return true;
                }
            }
        }       
        return handled;               
    } //ends invoke action
   
    public void takePicture()
    {
        try
        {
            String encoding = "encoding=jpeg&width=640&height=480&quality=normal";
            final byte[] imagebytes = videoControl.getSnapshot( encoding );           
            createImageScreen(imagebytes);
            // also have tried String encoding = "encoding=jpeg&width=640&height=480&quality=normal";
            // createImageScreen(videoControl.getSnapshot( encoding ));
        }
        catch(Exception e)
        {
            UiApplication.getUiApplication().pushModalScreen(new CustomDialog("ERROR "  + e.getClass() + ":  " + e.getMessage())); 
        } 
    } //ends takePicture
   
    private void createImageScreen( byte[] raw )
    {   
        // Initialize the screen
        ImageScreen imageScreen = new ImageScreen( raw );

        // Push this screen to display it to the user
        UiApplication.getUiApplication().pushScreen( imageScreen );
        UiApplication.getUiApplication().popScreen(this);
    } //ends createimagescreen
   
} //ends class

 

 

 

 

 

Contributor
slaphead400
Posts: 42
Registered: ‎05-17-2011
My Device: all

Re: getSnapShot not supported

sorry as an ammendment to the above, I nocied I started with the constructor definaition and not the class definition. In case it helps, this is above the constructor:

 

public class SnapShot extends MainScreen {
   
   BitmapField bitmapField;
   BitmapField spacerImage;
   private VideoControl videoControl;
   private Field videoField;

Retired
Retired
BVP
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified

Re: getSnapShot not supported

Hi slaphead400!

 

The getSnapshot method is not supported for video recording players, only still image capture players.  In other words, in your "Manager.createPlayer( "capture://video?encoding=video/3gpp" );" call change the 'video/3gpp' to either 'image/jpeg' or just 'jpeg' and the call should start working for you.

 

Let us know know how it turns out!

Contributor
slaphead400
Posts: 42
Registered: ‎05-17-2011
My Device: all

Re: getSnapShot not supported

Hi. Thanks for this. I added the whole encoding string with height, width and quality in there and then just called null and its working. I say working, in a version 5 emulator its working fine. In version 6 (torch 9800), the snapshot ares appears under my mainscreen and also doesn't appear to take into account that I specified not to be fullscreen. Instead I have my main screen, then I scroll down and my snapshot area appears. However when I take the snapshot and display it on another screen, that appears within my screen so not quite sure why its working on v5 and not v6. Will have a play but yes it is at least taking pictures now. Thanks for the advice.

 

New Contributor
hvilchez2005
Posts: 2
Registered: ‎04-06-2013
My Device: torch 9800

Re: getSnapShot not supported

Another alternative is using "capture://video", applied in CameraDemo, it also works.