示例#1
0
  private void showCamera() {
    try {
      mPlayer = Manager.createPlayer("capture://video");
      mPlayer.realize();

      mVideoControl = (VideoControl) mPlayer.getControl("VideoControl");

      Canvas canvas = new CameraCanvas(this, mVideoControl);
      canvas.addCommand(mBackCommand);
      canvas.addCommand(mCaptureCommand);
      canvas.setCommandListener(this);
      mDisplay.setCurrent(canvas);

      /*
      Form form = new Form("Camera form");
      Item item = (Item)mVideoControl.initDisplayMode(
          GUIControl.USE_GUI_PRIMITIVE, null);
      form.append(item);
      form.addCommand(mBackCommand);
      form.addCommand(mCaptureCommand);
      form.setCommandListener(this);
      mDisplay.setCurrent(form);
      */

      mPlayer.start();
    } catch (IOException ioe) {
      handleException(ioe);
    } catch (MediaException me) {
      handleException(me);
    }
  }
示例#2
0
 public void commandAction(Command c, Displayable s) {
   if (c.getCommandType() == Command.EXIT) {
     destroyApp(true);
     notifyDestroyed();
   } else if (c == mCameraCommand) showCamera();
   else if (c == mBackCommand) mDisplay.setCurrent(mMainForm);
   else if (c == mCaptureCommand) {
     capture();
   }
 }
示例#3
0
  public void capture() {
    try {
      // Get the image.
      byte[] raw = mVideoControl.getSnapshot(null);
      Image image = Image.createImage(raw, 0, raw.length);

      Image thumb = ImageUtility.createThumbnail(image);

      // Place it in the main form.
      if (mMainForm.size() > 0 && mMainForm.get(0) instanceof StringItem) mMainForm.delete(0);
      mMainForm.append(thumb);

      // Flip back to the main form.
      mDisplay.setCurrent(mMainForm);

      // Shut down the player.
      mPlayer.close();
      mPlayer = null;
      mVideoControl = null;
    } catch (MediaException me) {
      handleException(me);
    }
  }
示例#4
0
  public void startApp() {
    mDisplay = Display.getDisplay(this);

    mDisplay.setCurrent(mMainForm);
  }