O'Reilly logo

QuickTime for Java: A Developer's Notebook by Chris Adamson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Controlling a Movie Programmatically

For various reasons, an application might want to control the movie via its own method calls, in lieu of or in addition to the GUI provided by QuickTime’s MovieController. One example of this is Movie.start( ). You can programmatically issue many more commands, some of which you can’t issue with the default control.

How do I do that?

Example 2-4 shows a new class, BasicQTButtons.java. The main() is exactly the same as BasicQTPlayer, but the constructor has extra work to create some control buttons, and an actionPerformed( ) method implements AWT’s ActionListener.

Note

Compile and run this example with ant run-ch02-basicqtbuttons..

Example 2-4. Programmatic control of a movie

package com.oreilly.qtjnotebook.ch02; import quicktime.*; import quicktime.app.view.*; import quicktime.std.movies.*; import quicktime.io.*; import com.oreilly.qtjnotebook.ch01.QTSessionCheck; import java.awt.*; import java.awt.event.*; public class BasicQTButtons extends Frame implements ActionListener { Button revButton, stopButton, startButton, fwdButton; Movie theMovie; public BasicQTButtons (Movie m) throws QTException { super ("Basic QT Player"); theMovie = m; QTComponent qc = QTFactory.makeQTComponent (m); Component c = qc.asComponent( ); setLayout (new BorderLayout( )); add (c, BorderLayout.CENTER); Panel buttons = new Panel( ); revButton = new Button("<"); revButton.addActionListener (this); stopButton = new Button ("0"); stopButton.addActionListener (this); startButton ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required