Exporting Movies to Any Installed Format
Exporting to a list of known formats is limiting—if the end user has installed new movie exporters, either from third parties or via an update to QuickTime itself, a program that uses a canned list of exporters won’t be able to pick them up. Fortunately, QuickTime provides a means of querying for installed components of a given type. You can use this strategy to offer a list of all available exporters.
How do I do that?
The AdvancedMovieExport eliminates the three
canned entries in the choices array that were used
by SimpleMovieExport (shown in Example 4-2) and instead builds the array through a
process of discovery; this code would replace the short
“build choices” block in the
constructor for SimpleMovieExport but needs to go
inside the try-catch, because it makes calls that can throw
QTException:
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( ) + " **");Note ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access