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

Flattening a Movie

Saving a movie can mean different things in QuickTime: saving a reference movie, saving a self-contained movie, or exporting to a different format. Typically, though, the idea of creating a self-contained movie is what users think of as “saving”—they want a single file that doesn’t depend on any others, so they can put it on a server, email it to mom, etc. This process is called “flattening.”

Note

"Flattening” is also an old Mac OS term for turning a file with both a resource fork and a data fork into a single-fork file, suitable for use on non-Mac disk formats. In this book, we use “flatten” only in its QuickTime sense.

How do I do that?

The FlattenableQTEditor is similar to the SaveableQTEditor, adding the menu item and its typical GUI and action-handling support. The flattening is done in a doFlatten( ) method:

public void doFlatten( ) throws QTException { // always attempts to save to a new location, // so prompt for filename FileDialog fd = new FileDialog (this, "Flatten...", FileDialog.SAVE); fd.setVisible(true); // blocks if ((fd.getDirectory( ) = = null) || (fd.getFile( ) = = null)) return; QTFile flatFile = new QTFile (new File (fd.getDirectory( ), fd.getFile( ))); if (flatFile.exists( )) { // JOptionPane is a bit of cheat-for-clarity here, // building a working AWT dialog would be punitive int choice = JOptionPane.showConfirmDialog (this, "Overwrite " + flatFile.getName( ) + "?", "Flatten", JOptionPane.OK_CANCEL_OPTION); if (choice != JOptionPane.OK_OPTION) ...

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