import java.applet.*;
import java.awt.*;

public class Frames extends Applet
{
  public void init() 
  {
    //Read in an image and an audio clip
    String imageName = IMAGE;
    String audioName = AUDIO;

    String param = getParameter("image");
    
    if (param != null) {
      imageName = param;
    }
    
    param = getParameter("audio");
    
    if (param!=null) {
      audioName = param;
    }
    
    //Create a MediaTracker to inform us when the image has
    //been completely loaded.

    tracker = new MediaTracker (this);
    
    sound = getAudioClip(getCodeBase(), imageName);
    image = getImage(getCodeBase(), imageName);

    //add the image to the MediaTracker so that we can wait for it.
    
    tracker.addImage(image,0);
  }
  
  public void paint(Graphics g)
  {
    g.drawImage(image,0, 0, this);
  }
   
  //play the audio Clip
  
  public void start()
  {
    //Load the image and wait until it's done.

    try {
	tracker.waitForID(0);
    } catch (InterruptedException e)
    {
    }
    
    repaint();
    sound.play();
  }
  
  private static final String IMAGE="../project/batter4.gif";
  private static final String AUDIO= "gong.au";
  private Image image;
  private AudioClip sound;
  private MediaTracker tracker;
  
}

    
