FileDocCategorySizeDatePackage
SimpleMovieExport.javaAPI DocExample4358Wed Nov 10 12:56:06 GMT 2004com.oreilly.qtjnotebook.ch04

SimpleMovieExport

public class SimpleMovieExport extends Object

Fields Summary
Constructors Summary
public SimpleMovieExport()

        // build choices
        ExportChoice[] choices = new ExportChoice[3];
        choices[0] =
            new ExportChoice ("QuickTime Movie",
                              StdQTConstants.kQTFileTypeMovie);
        choices[1] =
            new ExportChoice ("AVI file",
                              StdQTConstants.kQTFileTypeAVI);
        choices[2] =
            new ExportChoice ("MPEG-4 file", 
                              // 0x6d706734);
                              QTUtils.toOSType("mpg4"));

        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);

            // 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.subtype);

            QTFile saveFile = new QTFile (new java.io.File("Untitled"));

            // do the export
            /* this works too
            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();
        }
        
    
Methods Summary
public static final voidmain(java.lang.String[] args)

        new SimpleMovieExport();