Showing a Movie’s Current Time
Advanced users, particularly those doing editing, would like to know a movie’s current time—i.e., where they are in the movie. The scrubber can provide a general idea of the movie’s current time, but certain applications call for an exact value.
How do I do that?
Example 2-5s
BasicQTTimeDisplay
code extends the
BasicQTController
by adding a
Label
to the bottom of the
Frame
. A
Swing Timer
calls
actionPerformed( )
every 250 milliseconds, and
this method checks the current time of the movie and resets the
label.
Note
The Swing version of Timer is used to ensure that changing the label occurs on the AWT event-dispatch thread.
Compile and run this examnple with ant run-ch02-basicqttimedisplay.
Example 2-5. Displaying the current time 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 BasicQTTimeDisplay extends Frame implements ActionListener { Movie theMovie; Label timeLabel; public BasicQTTimeDisplay (Movie m) throws QTException { super ("Basic QT Controller"); theMovie = m; MovieController mc = new MovieController(m); QTComponent qc = QTFactory.makeQTComponent (mc); Component c = qc.asComponent( ); setLayout (new BorderLayout( )); add (c, BorderLayout.CENTER); timeLabel = new Label ("-:--", Label.CENTER); add (timeLabel, BorderLayout.SOUTH); javax.swing.Timer ...
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.