interactive .swf in java application.

From: eeyimaya (eeyimaya_at_hotmail.com)
Date: 10/22/03

  • Next message: Jonathan Markwell: "Interoperability Investigation"
    Date: 22 Oct 2003 01:35:00 -0700
    
    

    Hello,
     
    I want to play my .swf interactive movies in my java application. But
    succeeded only in playing noninteractive movies. I searched the web,
    newsgroups.... but could not find the right solution. My configuration
    is WİndowXP, QuickTime 6.4, jdk1.4.1.....
    I tried the code below:

    HOW CAN I PLAY INTERACTIVE .SWF IN JAVA WITH QUICKTIME?????

    IT IS VERY IMPORTANT AND URGENT PLEASE......

    Sorry for the long message.......
    THANKS A LOT......
     
    import java.io.IOException;
    import java.io.FileNotFoundException;
    import quicktime.app.QTFactory;
    import quicktime.app.anim.Compositor;
    import quicktime.app.image.GraphicsImporterDrawer;
    import quicktime.app.image.ImagePresenter;
    import quicktime.app.image.ImageUtil;
    import quicktime.app.players.MoviePresenter;
    import quicktime.io.QTFile;
    import quicktime.io.OpenMovieFile;
    import quicktime.qd.QDRect;
    import quicktime.qd.QDGraphics;
    import quicktime.qd.QDColor;
    import quicktime.qd.QDConstants;
    import quicktime.std.StdQTConstants;
    import quicktime.std.movies.Movie;
    import quicktime.std.movies.media.FlashMedia;
    import quicktime.QTSession;
    import quicktime.QTException;

    /**
     * QTZoo Module 2 - Playing a movie
     *
     * @author Michael Hopkins
     * @author Levi Brown
     * @author Apple Computer, Inc.
     * @version 1.0.1 11/15/1999
     *
     * Copyright: © Copyright 1999 Apple Computer, Inc. All rights
    reserved.
     */
    public class AnimalPane
    {
            public AnimalPane()
            {
                    QDRect size = new QDRect(Zoo2.WIDTH, Zoo2.HEIGHT);
            
                    try
                    {
                            QDGraphics gw = new QDGraphics( size ); // create a new graphics
    object
                            compositor = new Compositor( gw, QDColor.white, 30, 1 );
                            QTFile imageFile = new QTFile( QTFactory.findAbsolutePath(
    "data/zebra/ZebraBackground.jpg" ));
                            GraphicsImporterDrawer drawer = new GraphicsImporterDrawer(
    imageFile );
                            ImagePresenter presenter =
    ImagePresenter.fromGraphicsImporterDrawer( drawer );
                            presenter.setLocation( 110, 110 ); // set location of movie
    within compositor
                            compositor.addMember( presenter, 2 ); // add image presenter to
    compositor in 2nd layer
                            Movie m = makeMovie( new QTFile(
                            QTFactory.findAbsolutePath( "data/zebra/ships.mov")));
                            md = new MoviePresenter( m ); // create presenter from movie
    file
                            compositor.addMember( md, 1 ); // add presenter to compositor
                            compositor.getTimer().setRate(1); // start compositor
                            md.setRate(1); // start movie
                    }
                    catch ( IOException e ) // catch any errors
                    {
                            e.printStackTrace();
                    }
                    catch ( QTException e )
                    {
                            e.printStackTrace();
                    }
            }

            public Compositor getCompositor( ) { return compositor; } // returns
    the compositor associated with the animal pane
            /**
             * Opens the movie file and sets it up to be played.
             * @param f a QTFile representing the movie to initialize.
             * @return the movie, ready to play
             */
            protected Movie makeMovie( QTFile f ) throws IOException, QTException
            {
                    OpenMovieFile movieFile = OpenMovieFile.asRead(f);
                    Movie m = Movie.fromFile( movieFile );
                    
                    //m.getTimeBase().setFlags( StdQTConstants.loopTimeBase );// we want
    the movie to loop
                    m.getTimeBase().setFlags( StdQTConstants.mcInfoMovieIsInteractive);
                    return m;
            }
            
            protected Compositor compositor;
            protected MoviePresenter md;
    }

    ************************************************
    import java.awt.*;
    import java.awt.event.*;
    import java.io.IOException;

    import quicktime.QTSession;
    import quicktime.QTException;

    import quicktime.app.display.QTCanvas;

    /**
     * QTZoo Module 2 - Playing a Movie
     * This application requires QuickTime for Java
     *
     * @author Michael Hopkins
     * @author Levi Brown
     * @author Apple Computer, Inc.
     * @version 1.0.2 10/21/1999
     *
     * Copyright: © Copyright 1999 Apple Computer, Inc. All rights
    reserved.
     *
     */
     
    public class Zoo2 extends Frame
    {
            static public int WIDTH = 800;
            static public int HEIGHT = 600;
            
            public Zoo2( String s )
            {
                    super(s);
                    setResizable( false ); // we don't want the window to resize
                    setBounds( 0, 0, WIDTH, HEIGHT ); // make window 640x480
                    QTCanvas myQTCanvas = new QTCanvas( QTCanvas.kInitialSize, 0.5F,
    0.5F );
                    add( myQTCanvas );
                    AnimalPane zebraPane = new AnimalPane(); // load media
                    try
                    {
                            myQTCanvas.setClient( zebraPane.getCompositor(), true );
                    }
                    catch ( QTException e )
                    {
                            e.printStackTrace();
                    }
                    addWindowListener( new WindowAdapter() // anonymous inner class
    for handling window events
                    {
                            public void windowClosing( WindowEvent we )
                            {
                                    QTSession.close(); // shut down QT and clean up
                                    dispose(); // destroy window
                            }
                            public void windowClosed( WindowEvent we )
                            {
                                    System.exit( 0 ); // exit to shell
                            }
                    });
            }

            /**
             * Main entry point for the application
             */
            public static void main( String[] args )
            {
                    try
                    {
                            QTSession.open(); // perform native QuickTime initialization
                            Zoo2 appWindow = new Zoo2( "QTZoo2" ); // create a new application
    window
                            appWindow.show(); // make the window visible
                            appWindow.toFront(); // bring it to the front
                    }
                    catch ( Exception e ) // handle any exceptions
                    {
                            QTSession.close();
                            e.printStackTrace();
                    }
            }
    }


  • Next message: Jonathan Markwell: "Interoperability Investigation"

    Relevant Pages

    • interactive .swf in java application.
      ... I want to play my .swf interactive movies in my java application. ... succeeded only in playing noninteractive movies. ... * QTZoo Module 2 - Playing a movie ...
      (comp.lang.java.programmer)
    • interactive .swf in java application.
      ... I want to play my .swf interactive movies in my java application. ... succeeded only in playing noninteractive movies. ... * QTZoo Module 2 - Playing a movie ...
      (comp.lang.java.softwaretools)
    • Re: A Little Guitar Music
      ... This is not a Martin, its a Euphonon guitar, built by the Larsons in ... One of the good trio was playing a Martin, ... Just for the heck of it, I wanted to see if just that movie could be ...
      (rec.music.makers.guitar.acoustic)
    • Help - guitar arpeggio tips?
      ... I heard a cover of "Help" while watching a movie the other night, so I picked up my old Guild and started playing along. ... This is one way that I've been deciding what songs are in my "playing for my own enjoyment" repertoire the last couple of years. ... I did read somewhere that George complained that it was hard to play the notes in even, ...
      (rec.music.beatles)
    • Re: Looping AVI Playback via FilterGraph API
      ... >I'm building a filter graph in Direct Show, ... >will cause the movie to do this? ... Playing videos backwards is going to be tough, ...
      (microsoft.public.win32.programmer.directx.video)