Code Example
The following example shows an AWT file-selection dialog and then tries to import and play the selected media file.
import java.io.File; import java.awt.*; import quicktime.*; import quicktime.std.movies.Movie; import quicktime.app.view.QTFactory; import quicktime.io.*; public class TrivialQTJPlayer extends Frame { public static void main (String args) { try { QTSession.open; Frame f = new TrivialQTJPlayer; f.pack; f.setVisible (true); } catch (Exception e) { e.printStackTrace; } } public TrivialQTJPlayer throws QTException { FileDialog fd = new FileDialog (this, "TrivialJMFPlayer", FileDialog.LOAD); fd.setVisible(true); 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); m.start; } }Most of the code in this example involves itself with setting up the GUI. The only calls to QTJ are the calls to OpenMovieFile.asRead
and Movie.fromFile
, which create a QuickTime movie from the specified file, and the calls to create an AWT component from the QTFactory
. This example puts the movie into the frame and immediately starts playing it; if a control bar (aka a "scrubber") were desired, you would create a MovieController
from the Movie
and then create a component from the controller, rather than from the movie.
Read more about this topic: Quick Time For Java
Famous quotes containing the word code:
“Hollywood keeps before its child audiences a string of glorified young heroes, everyone of whom is an unhesitating and violent Anarchist. His one answer to everything that annoys him or disparages his country or his parents or his young lady or his personal code of manly conduct is to give the offender a sock in the jaw.... My observation leads me to believe that it is not the virtuous people who are good at socking jaws.”
—George Bernard Shaw (18561950)
“Faultless honesty is a sine qua non of business life. Not alone the honesty according to the moral code and the Bible. When I speak of honesty I refer to the small, hidden, evasive meannesses of our natures. I speak of the honesty of ourselves to ourselves.”
—Alice Foote MacDougall (18671945)