interactive .swf in java application.

Discussion in 'Java' started by eeyimaya, Oct 22, 2003.

  1. eeyimaya

    eeyimaya Guest

    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();
    }
    }
    }
     
    eeyimaya, Oct 22, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. DzemoT.

    ASP.NET & *.swf(Flash files)

    DzemoT., Jan 12, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    13,687
    Udayakumar
    Jan 13, 2004
  2. Trint Smith
    Replies:
    0
    Views:
    515
    Trint Smith
    Feb 27, 2004
  3. WJ
    Replies:
    2
    Views:
    510
  4. senior
    Replies:
    2
    Views:
    726
    Daniel Pitts
    Feb 25, 2007
  5. Pedro Pinto

    Java Applet with Swf

    Pedro Pinto, Jun 27, 2007, in forum: Java
    Replies:
    5
    Views:
    1,638
    Pedro Pinto
    Jun 28, 2007
Loading...

Share This Page