January 2005
Intermediate to advanced
256 pages
6h 34m
English
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.
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.
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 ...Read now
Unlock full access