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 ...

Get QuickTime for Java: A Developer's Notebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.