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

public class PlayLoop extends Applet implements Runnable
{
        Thread t = null;
        String soundFileName=null;
        String delayString;
        int delayInt;
        public void init()
        {
        t = null;

        soundFileName = getParameter("soundfile");
        System.out.println("sound file = " + soundFileName);

        delayString = getParameter("delay");
        delayInt = Integer.parseInt(delayString);
        System.out.println("delay = " + delayInt);

        }
        public void start()
        {
        if (t == null)
                t = new Thread(this);
        t.start();

        }

        public void stop()
        {
        if (t != null)
                t.stop();
        t = null;                        

        }

        public void run()
        {
                while (t != null)
                {
                        play(getCodeBase(), soundFileName);
                        try {t.sleep(delayInt);}
                        catch (Exception e) {System.out.println("Exception occurred: " + e.toString());}
                }

        }

}
