/*
* SampleGazelleApplet.java
*
* This is based on GazellePlayerApplet.java
*
* Created on March 24, 2002, 11:00 AM
*/
import com.kitfox.gazelle.project.graphics.*;
import java.net.*;
/**
* This is a generic applet which can be inserted into a web page
to run a
* Gazelle movie.
*
* @author Mark McKay
*/
public class SampleGazelleApplet extends javax.swing.JApplet
implements PlayerThreadListener
{
MoviePlayer moviePlayer;
GazelleProject project;
PlayerThread playerThread;
/** Creates new form GazellePlayerApplet */
public GazellePlayerApplet () {
moviePlayer = new MoviePlayer();
getContentPane().add("Center", moviePlayer);
project = null;
}
public void init()
{
//Load file
String path = getParameter("path");
String proj = getParameter("project");
if (path == null || proj == null) return;
try {
URL pathURL = new URL(getCodeBase(),
path);
project = new GazelleProject(pathURL,
proj, this);
}
catch (Exception e) { e.printStackTrace(); }
if (project == null) return;
moviePlayer.setProject(project);
//Start thread
playerThread = new PlayerThread(moviePlayer);
playerThread.start();
playerThread.addPlayerThreadListener(this);
//Now signal thread to start the animation
playerThread.forward();
}
/**
* Player event notification
*/
public void playerThreadEvent (int evt)
{
//Loop when we get to the end of the movie - note
that this is not necessary
// if the movie has it's loop attribute checked.
It is included here to
// demonstrate the PlayerThreadListener
if (evt == PlayerThreadListener.EV_STOP)
{
playerThread.firstFrame();
playerThread.forward();
}
}
}