try {
// query user for a movie to open
QTSessionCheck.check();
QTFile file =
QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
OpenMovieFile omFile = OpenMovieFile.asRead (file);
Movie movie = Movie.fromFile (omFile);
// build up list of suitable components
Vector choices = new Vector();
ComponentIdentifier ci = null;
ComponentDescription cd =
new ComponentDescription(StdQTConstants.movieExportType);
while ( (ci = ComponentIdentifier.find(ci, cd)) != null) {
// check to see that the movie can be exported
// with this component (this throws some obnoxious
// exceptions, maybe a bit expensive?)
try {
MovieExporter exporter = new MovieExporter (ci);
if (exporter.validate (movie, null)) {
ExportChoice choice =
new ExportChoice (ci.getInfo().getName(),
ci);
choices.addElement(choice);
}
} catch (StdQTException expE) {
System.out.println ("** can't validate " +
ci.getInfo().getName() + " **");
// expE.printStackTrace();
} // ow!
}
// offer a choice of movie exporters
JComboBox exportCombo = new JComboBox (choices);
JOptionPane.showMessageDialog (null,
exportCombo,
"Choose exporter",
JOptionPane.PLAIN_MESSAGE);
ExportChoice choice =
(ExportChoice) exportCombo.getSelectedItem();
System.out.println ("chose " + choice.name);
// create an exporter
MovieExporter exporter = new MovieExporter (choice.identifier);
QTFile saveFile = new QTFile (new java.io.File("Untitled"));
// do the export
/* this works too, assuming you set a file up front
exporter.toFile (saveFile,
movie,
null,
0,
movie.getDuration());
*/
movie.setProgressProc();
movie.convertToFile (null,
saveFile,
StdQTConstants.kQTFileTypeMovie,
StdQTConstants.kMoviePlayer,
IOConstants.smSystemScript,
StdQTConstants.showUserSettingsDialog |
StdQTConstants.movieToFileOnlyExport |
StdQTConstants.movieFileSpecValid, // flags
exporter);
// need to explicitly quit (since awt is running)
System.exit(0);
} catch (QTException qte) {
qte.printStackTrace();
}