×

Discussion Board

Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    4

    VideoControl in a Form

    Hi,

    I'm coding a MIDlet for 6086 and a N95 devices that has to use the camera of the device, using the VideoControl way.
    Initialy I had used the Canvas approach, which works fine. But since I'm also using J2ME Polish I'm trying to use the Form version.
    The problem is that....nothing happens when I send to the Display the instance of my Form.
    I've found out that videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "javax.microedition.lcdui.Item") does not return an instance of Item but an instance of javax.microedition.lcdui.MMItemImpl which I can't find in the Javadoc.

    Is there a solution to get the video control displayed in a form?

    Thanks,

    This is the code of my Form that I then send to the Display of my IDlet:

    Code:
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Item;
    import javax.microedition.lcdui.StringItem;
    import javax.microedition.media.*;
    import javax.microedition.media.control.*;
    
    import java.io.IOException;
    
    public class CameraForm extends Form{
    	
    	private Player player;
    	private VideoControl videoControl;
    		private boolean active;
    	private StringItem messageItem;
    	
    	CameraForm(String title){
    		//#style mainScreen
    		super(title);
    		
    		messageItem = new StringItem("Message", "start");
    		append(messageItem);
    		// initialise the camera
    		try{
    			player = Manager.createPlayer("capture://video");
    			player.realize();
    			
    			videoControl = (VideoControl)(player.getControl("VideoControl"));
    			if(videoControl != null){
    				Object obj = videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "javax.microedition.lcdui.Item");
    				append((Item)(videoControl.initDisplayMode(VideoControl.USE_GUI_PRIMITIVE, "javax.microedition.lcdui.Item")));
    			}
    
    		}
    		catch(IOException ioe){
    			messageItem.setText("IOException:"+ioe.getMessage());
    		}
    		catch(MediaException me){
    			messageItem.setText("MediaException:"+me.getMessage());
    		}
    		catch(SecurityException se){
    			messageItem.setText("SecurityException:"+se.getMessage());
    		}
    		catch(Exception e){
    			e.printStackTrace();
    			messageItem.setText("Exception:"+e.getMessage());
    		}
    	}
    	
    	public synchronized void start() {
    		if (!active){
    			try{
    				if (player!=null){
    					player.start();
    				}
    				if (videoControl!=null){
    					videoControl.setVisible(true);
    				}
    			}
    			catch(MediaException me){
    				messageItem.setText("MediaException:"+me.getMessage());
    				me.printStackTrace();
    			}
    			catch(SecurityException se){
    				messageItem.setText("SecurityException:"+se.getMessage());
    			}
    			active = true;
    		}
    	}
    	
    	public synchronized void stop() {
    		if (active){
    			try{
    				if (videoControl != null){
    					videoControl.setVisible(false);
    				}
    				if (player != null){
    					player.stop();
    				}
    			}
    			catch (MediaException me){
    				messageItem.setText("MediaException:"+me.getMessage());				
    			}
    			active = false;
    		}
    	}
    	
    	public byte[] getSnapshot(){
    		byte[] result = null;
    		try{
    			result = videoControl.getSnapshot(null);
    		}
    		catch(MediaException me){
    			messageItem.setText("MediaException:"+me.getMessage());
    		}
    		return result;
    	}
    	
    }

  2. #2
    Nokia Developer Expert
    Join Date
    Aug 2007
    Posts
    1,595

    Re: VideoControl in a Form

    Hello SurfingPop,


    This is from the MMAPI specs:

    "When USE_GUI_PRIMITIVE is specified for initDisplayMode, a GUI primitive will be returned. This object is where the GUI of this control will be displayed. It can be used in conjunction with other GUI objects, and conforms to the GUI behaviors as specified by the platform.

    For a given platform, the object returned must implement or extend from the appropriate GUI primitive of the platform. For platforms that support only AWT such as some CDC implementations, the object must extend from java.awt.Component; for MIDP implementations with only LCDUI support, it must extend from javax.microedition.lcdui.Item.

    In these cases, the arg argument must be null or a String that specifies the fully-qualified classname of the GUI primitive.

    On some platforms that support multiple types of GUI primitives, the arg argument must be used to arbitrate among the options. The arg argument must be a String that specifies the fully-qualified classname of the GUI primitive to be returned by the method."

    As for the previous, AFAIK it's not possible to do in the way you're referring to (=using a J2ME Polish Form).

    For Nokia phones, please refer to this article (under headline "Play Back Video on a Form") regarding Forms with VideoControl:

    http://www.informit.com/articles/art...75708&seqNum=3


    Regards,
    r2j7

Similar Threads

  1. second form not getting key events
    By krsunil in forum Symbian User Interface
    Replies: 3
    Last Post: 2008-12-10, 10:29
  2. Form troubles
    By matdodgson in forum Symbian User Interface
    Replies: 2
    Last Post: 2008-12-06, 10:49
  3. problems in creating multipage form
    By A.Vogel in forum Symbian User Interface
    Replies: 0
    Last Post: 2007-10-02, 08:16
  4. How to pass variable between form
    By imagina23 in forum Mobile Java General
    Replies: 1
    Last Post: 2006-06-15, 18:29
  5. Form not displaying
    By Shabs in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-07-09, 16:38

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×