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

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

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