FileDocCategorySizeDatePackage
CompositeVideoTracks.javaAPI DocExample4256Wed Nov 10 12:54:52 GMT 2004com.oreilly.qtjnotebook.ch08

CompositeVideoTracks

public class CompositeVideoTracks extends Frame

Fields Summary
static Movie
foreMovie
static Movie
backMovie
Constructors Summary
public CompositeVideoTracks(Movie backMovie, Movie foreMovie)

        super ("Composite Video Tracks");
        Movie matrixMovie = new Movie();
        // build tracks
        Track foreTrack = addVideoTrack (foreMovie, matrixMovie);
        Track backTrack = addVideoTrack (backMovie, matrixMovie);
        // set graphicsmode composite
        GraphicsMode gm = new GraphicsMode (QDConstants.addMax,
                                            QDColor.green);
        VisualMediaHandler foreHandler = 
            (VisualMediaHandler) foreTrack.getMedia().getHandler();
        foreHandler.setGraphicsMode(gm);
        foreTrack.setLayer(-1);
        // now get component and add to frame
        MovieController controller = new MovieController(matrixMovie);
        Component c = QTFactory.makeQTComponent(controller).asComponent();
        add (c);
    
Methods Summary
public TrackaddVideoTrack(Movie sourceMovie, Movie targetMovie)

 
        Track videoTrack = 
            sourceMovie.getIndTrackType (1,
                                         StdQTConstants.videoMediaType,
                                         StdQTConstants.movieTrackMediaType);
        if (videoTrack == null)
            throw new QTException ("can't find a video track");
        // add videoTrack to targetMovie
        Track newTrack =
            targetMovie.newTrack (videoTrack.getSize().getWidthF(),
                                  videoTrack.getSize().getHeightF(),
                                  1.0f);
        VideoMedia newMedia = 
            new VideoMedia (newTrack,
                            videoTrack.getMedia().getTimeScale(),
                            new DataRef(new QTHandle()));
        videoTrack.insertSegment (newTrack,
                                 0,
                                 videoTrack.getDuration(),
                                 0);
        return newTrack;
    
public static voidmain(java.lang.String[] args)

        try {
            QTSessionCheck.check();
            // get background movie
            QTFile file = QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
            OpenMovieFile omf = OpenMovieFile.asRead(file);
            backMovie = Movie.fromFile (omf);
            // get foreground movie
            file = QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
            omf = OpenMovieFile.asRead(file);
            foreMovie = Movie.fromFile (omf);
            // get frame
            Frame frame = new CompositeVideoTracks (backMovie, foreMovie);
            frame.pack();
            frame.setVisible (true);
        } catch (QTException qte) {
            qte.printStackTrace();
        }