// Copyright 1996, Marimba Inc. All Rights Reserved.


// @(#)PlayerApplet.java, 1.5, 10/10/96





package marimba.gui;





import java.awt.*;


import java.net.*;


import java.applet.*;





import marimba.util.*;





/**


 * An applet wrapper for Presentations. To display a presentation in


 * an HTML page you need to put use following applet tag:


 * <pre>


 *	&lt;applet code=marimba.gui.PlayerApplet width=300 height=200&gt;


 *	&ltparam name=presentation value=example.gui&gt


 *	&lt/applet&gt


 * </pre>


 * In addtion to that you need to make sure that the marimba classes


 * are accessible to the applet. Note that scripting does not work


 * inside most browsers.


 *


 * @author	Arthur van Hoff


 * @version 	1.5, 10/10/96


 */


public class PlayerApplet extends Applet {


    /**


     * The playerpanel for this applet.


     * @see #getPlayerPanel


     */


    public PlayerPanel  player;





    /**


     * Initialize the applet.


     */


    public void init() {


	ThreadUtil.systemGroup = Thread.currentThread().getThreadGroup();





	try {


	    String name = getParameter("presentation");


	    if (name == null) {


		System.out.println("No Presentation specified");


		return;


	    }


	    System.out.println("Loading: " + name);


	    URL url = new URL(getDocumentBase(), name);


	    Presentation presentation = Presentation.getPresentation(url);


	    setLayout(new BorderLayout());


	    player = new PlayerPanel(this);


	    add("Center", player);


	    player.setPresentation(presentation);


	} catch (MalformedURLException e) {


	    e.printStackTrace();


	}


    }





    /**


     * Get the PlayerPanel.


     * @see #player


     */


    public PlayerPanel getPlayerPanel() {


	return player;


    }





    /**


     * Start the applet.


     */


    public void start() {


	if (player != null) {


	    player.start();


	}


    }





    /**


     * Stop the applet.


     */


    public void stop() {


	if (player != null) {


	    player.stop();


	}


    }





    /**


     * Destroy the applet.


     */


    public void destroy() {


	if (player != null) {


	    player.destroy();


	}


    }


}


