The SimplePlayer Application

As discussed in the last chapter, using these APIs is the best way to get a feel for them. To demonstrate QuickTime, look at the SimplePlayer example. This player can load and play a variety of media formats, including QuickTime movies and MP3 audio files. Additionally, the application allows you to export files to other formats, demonstrating that facet of the QuickTime API. As they are put to use in SimplePlayer, try to recognize the key classes and methods from the last section.

The source for this application, shown in Example 10-1, is surprisingly concise. Much of this code is actually spent in setup and user interface. The actual QuickTime APIs used are fairly simple to understand.

Example 10-1. The SimplePlayer application

package com.wiverson.macosbook.quicktime; import quicktime.std.movies.Movie; import java.awt.event.*; import quicktime.QTException; import quicktime.io.QTFile; import java.awt.FileDialog; import java.awt.Frame; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JDialog; public class SimpleMoviePlayer extends javax.swing.JFrame implements quicktime.std.StdQTConstants, quicktime.Errors, quicktime.io.IOConstants { public static void main(String args[]) { try { // Required to initialize the QuickTime environment. // Performs checks to ensure QuickTime is installed and // also loads and sets up QuickTime. quicktime.QTSession.open( ); SimpleMoviePlayer myPlayer = new SimpleMoviePlayer("Simple ...

Get Mac OS X for Java Geeks 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.