I want to take photo in my j2me application. It runs well on the emulator, but it exited without any error message when on E52.
I just know that the application would crash if the VideoControl.setVisable(true) was called.
Here are all the codes:
Please help me! Thank you very much!Code:import java.io.IOException; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Command; import javax.microedition.lcdui.CommandListener; import javax.microedition.lcdui.Displayable; import javax.microedition.lcdui.Graphics; import javax.microedition.media.Manager; import javax.microedition.media.MediaException; import javax.microedition.media.Player; import javax.microedition.media.control.VideoControl; import com.crm.ui.base.DeviceScreen; import com.crm.ui.base.FrameSession; import com.crm.ui.base.Theme; public class CameraCanvas extends Canvas implements CommandListener { private VideoControl mVideoControl; private Player mPlayer; private DeviceScreen previous; private final Command back; public CameraCanvas(DeviceScreen previous) { this.previous = previous; back = new Command("back", Command.BACK, 2); addCommand(back); setCommandListener(this); openResource(); } private void openResource() { try { mPlayer = Manager.createPlayer(FrameSession.playerParameter); mPlayer.realize(); mVideoControl = (VideoControl) mPlayer.getControl("VideoControl"); mVideoControl.initDisplayMode(VideoControl.USE_DIRECT_VIDEO, this); mPlayer.start(); mVideoControl.setVisible(true); mVideoControl.setDisplaySize(140, 140); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MediaException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (Throwable e) { } } private void closeResource() { mVideoControl = null; if (mPlayer != null) { try { mPlayer.close(); } catch (Throwable e) { e.printStackTrace(); } mPlayer = null; } } protected void paint(Graphics g) { g.setColor(Theme.WHITE); g.fillRect(0, 0, getWidth(), getHeight()); } public void commandAction(Command c, Displayable d) { if (c == back) { closeResource(); previous.show(); } } }

Reply With Quote



