Saturday, May 1, 2010

Testing QuickTime for Java

I am experimenting with various media supporting libraries for Java these days. Java Media Framework (JMF) in the previous post is one of them.
I also found this interesting library provided by QuickTime. But it works only with QuickTime player. Given below are the steps I followed and a sample code I tested.

The first step is to install QuickTime. In QuickTime you can find a the java library QuickTime for Java in the part QuickTime/QTSystem/ This contains all the libraries needed.
I imported this to Eclipse and tried the following sample code provided in QuickTime for Java Wiki page (

import java.awt.*;

import quicktime.*;
import quicktime.std.movies.Movie;

public class TrivialQTJPlayer extends Frame {
public static void main (String[] args) {
try {;
Frame f = new TrivialQTJPlayer();
f.setVisible (true);
} catch (Exception e) {
public TrivialQTJPlayer()
throws QTException {
FileDialog fd = new FileDialog
(this, "TrivialJMFPlayer", FileDialog.LOAD);
File f = new File (fd.getDirectory(), fd.getFile());
OpenMovieFile omf = OpenMovieFile.asRead (new QTFile (f));
Movie m = Movie.fromFile (omf);
Component c = QTFactory.makeQTComponent(m).asComponent();
add (c);


This code creates a QTJ player and you have to give a *.mov file as input for this sample. There are many other file types supported by QT for Java.
The only constraint with this is that you must have a QuickTime player to run any application you've written by using QuickTime for java.

No comments:

Post a Comment