MainForm.java
上传用户:sygbg6
上传日期:2020-12-29
资源大小:4884k
文件大小:2k
- package cn.com.imageanalyze;
- import java.io.IOException;
- import javax.microedition.lcdui.Canvas;
- import javax.microedition.lcdui.Command;
- import javax.microedition.lcdui.CommandListener;
- import javax.microedition.lcdui.Display;
- import javax.microedition.lcdui.Displayable;
- import javax.microedition.lcdui.Form;
- import javax.microedition.lcdui.Item;
- import javax.microedition.media.Manager;
- import javax.microedition.media.MediaException;
- import javax.microedition.media.Player;
- import javax.microedition.media.control.VideoControl;
- import javax.microedition.midlet.MIDlet;
- import javax.microedition.midlet.MIDletStateChangeException;
- import cn.com.imageanalyze.customform.Parent;
- import cn.com.imageanalyze.customform.dialog.MessageDialog;
- public class MainForm extends Parent implements CommandListener
- {
- Player p;
- VideoControl vc;
- Form form;
- Command c1;
- public void commandAction(Command arg0, Displayable arg1) {
- if (arg0 == c1) {
- // MessageDialog mdd = new MessageDialog("分析结果",this);
- // mdd.setContent("1");
- // mdd.show();
- (new ShotCutThread(this,vc)).start();
- }
- }
- public void reinit() {
- // TODO Auto-generated method stub
- if(p != null){
- try {
- p.stop();
- } catch (MediaException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- p.close();
- p = null;
- }
- }
- public void finish(byte[] buff){
- reinit();
- (new SendThread(this,buff)).start();
-
- }
- public void show() {
- // TODO Auto-generated method stub
- reinit();
- try {
- p = Manager.createPlayer("capture://video?encoding=png&width=320&height=240");
- //capture://video?encoding=png&width=320&height=240
- p.realize();
- p.prefetch();
- vc = (VideoControl) p.getControl("VideoControl");
- if (vc != null) {
- form = new Form("video");
- form.append((Item)vc.initDisplayMode(vc.USE_GUI_PRIMITIVE,null));
- c1 = new Command("扫描", Command.OK, 1);
- form.addCommand(c1);
- form.setCommandListener(this);
- //vc.setDisplayFullScreen(true);
- Display.getDisplay(this).setCurrent(form);
- }
- p.start();
- } catch (IOException ioe) {
- } catch (MediaException me) {
- }
- }
- protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
- // TODO Auto-generated method stub
- }
- protected void pauseApp() {
- // TODO Auto-generated method stub
- }
- }