public static void main(String args[]) {
    try {
      QTSession.open();
      GroupDrawing frame = new GroupDrawing("QT in Java");

      frame.pack();
      frame.show();
      frame.toFront();
    } catch (Exception e) {
      e.printStackTrace();
      QTSession.close();
    }
  }
  public void init() {
    try {
      if (QTSession.isInitialized() == false) QTSession.open();
      // set up a QTComponent which will disply its content
      // at its original size of smaller and centered in the space given
      // to the QTComponent when the applet is layed out
      setLayout(new BorderLayout());
      QTFile qtf = new QTFile(getCodeBase().getFile() + getParameter("file"));
      OpenMovieFile fis = OpenMovieFile.asRead(qtf);
      mov = Movie.fromFile(fis);
      qtc = QTFactory.makeQTComponent(mov);

    } catch (QTException qtE) {
      throw new RuntimeException(qtE.getMessage());
    }
  }
  public void dispose() {
    if (readyForFrames) finish();

    try {
      QTSession.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
  /**
   * Create a movie with the specified width, height, filename, frame rate, codec type and quality,
   * and key frame rate.
   */
  public MovieMaker(
      PApplet p,
      int _w,
      int _h,
      String _filename,
      int _rate,
      int _codecType,
      int _codecQuality,
      int _keyFrameRate) {
    parent = p;

    width = _w;
    height = _h;
    rate = _rate;

    try {
      QTSession.open();
    } catch (QTException e1) {
      e1.printStackTrace();
    }

    try {
      ImageDescription imgD = null;
      if (quicktime.util.EndianOrder.isNativeLittleEndian()) {
        imgD = new ImageDescription(QDConstants.k32BGRAPixelFormat);
      } else {
        imgD = new ImageDescription(QDGraphics.kDefaultPixelFormat);
      }
      imgD.setWidth(width);
      imgD.setHeight(height);
      gw = new QDGraphics(imgD, 0);

    } catch (QTException e) {
      e.printStackTrace();
    }
    codecType = _codecType;
    codecQuality = _codecQuality;
    keyFrameRate = _keyFrameRate;
    initMovie(_filename);

    parent.registerDispose(this);
  }
 public void destroy() {
   QTSession.close();
 }