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; } }

Reply With Quote

