FileDocCategorySizeDatePackage
BasicQTStepper.javaAPI DocExample4621Wed Nov 10 12:55:28 GMT 2004com.oreilly.qtjnotebook.ch02

BasicQTStepper

public class BasicQTStepper extends Frame implements ActionListener

Fields Summary
Button
revButton
Button
stopButton
Button
startButton
Button
fwdButton
Movie
theMovie
Track
visualTrack
Constructors Summary
public BasicQTStepper(Movie m)

        super ("Basic QT Player");
        theMovie = m;
        visualTrack =
            m.getIndTrackType (1,
                               StdQTConstants.visualMediaCharacteristic,
                               StdQTConstants.movieTrackCharacteristic);
        if (visualTrack != null) 
            System.out.println ("found visual track " + visualTrack);
        // layout
        QTComponent qc = QTFactory.makeQTComponent (m);
        Component c = qc.asComponent();
        setLayout (new BorderLayout());
        add (c, BorderLayout.CENTER);
        Panel buttons = new Panel();
        revButton = new Button("-");
        revButton.addActionListener (this);
        if (visualTrack == null)
            revButton.setEnabled(false);
        stopButton = new Button ("0");
        stopButton.addActionListener (this);
        startButton = new Button ("1");
        startButton.addActionListener (this);
        fwdButton = new Button ("+");
        fwdButton.addActionListener (this);
        if (visualTrack == null)
            fwdButton.setEnabled(false);
        buttons.add (revButton);
        buttons.add (stopButton);
        buttons.add (startButton);
        buttons.add (fwdButton);
        add (buttons, BorderLayout.SOUTH);
        pack();
    
Methods Summary
public voidactionPerformed(java.awt.event.ActionEvent e)

        try {
            if (e.getSource() == revButton) {
                TimeInfo ti =
                    visualTrack.getNextInterestingTime (
                          StdQTConstants.nextTimeMediaSample,
                          theMovie.getTime(),
                          -1);
                theMovie.setTime (new TimeRecord (theMovie.getTimeScale(),
                                                  ti.time));
            }
            else if (e.getSource() == stopButton)
                theMovie.stop();
            else if (e.getSource() == startButton)
                theMovie.start();
            else if (e.getSource() == fwdButton) {
                TimeInfo ti =
                    visualTrack.getNextInterestingTime (
                          StdQTConstants.nextTimeMediaSample,
                          theMovie.getTime(),
                          1);
                theMovie.setTime (new TimeRecord (theMovie.getTimeScale(),
                                                  ti.time));
            }
        } catch (QTException qte) {
            qte.printStackTrace();
        }
    
public static voidmain(java.lang.String[] args)

        try {
            QTSessionCheck.check();
            QTFile file =
                QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
            OpenMovieFile omFile = OpenMovieFile.asRead (file);
            Movie m = Movie.fromFile (omFile);
            Frame f = new BasicQTStepper (m);
            f.pack();
            f.setVisible(true);
            m.start();
        } catch (Exception e) {
            e.printStackTrace();
        }