// plain audio looper
//	-lynx@java.pages.de

import java.applet.Applet;
import java.applet.AudioClip;

public class AudioLoop extends Applet {
	String url, url2, murl, murl2;
	AudioClip au, au2;
	int delay = 1000;

	public void init() {
		url = getParameter("loop");
		url2 = getParameter("cul8r");
		murl = getParameter("myloop");
		murl2 = getParameter("mycul8r");

		if (url != null) {
			au = getAudioClip(getCodeBase(), url);
		} else if (murl != null) {
			au = getAudioClip(getDocumentBase(), murl);
		} else {
			au = getAudioClip(getCodeBase(), "loops/spacemusic.au");
		}

		if (url2 != null) {
			au2 = getAudioClip(getCodeBase(), url2);
		} else if (murl2 != null) {
			au2 = getAudioClip(getDocumentBase(), murl2);
			// } else {
			// au2 = getAudioClip(getCodeBase(), "fx/sun/bong.au");
		}

		String tmp = getParameter("delay");
		if (tmp != null)
			delay = Integer.parseInt(tmp);
	}

	public synchronized void start() {
		if (au != null) {
			try {
				Thread.sleep(delay);
			} catch (InterruptedException e) {
			}

			au.loop();
		}
	}

	public synchronized void stop() {
		if (au != null)
			au.stop();
		if (au2 != null)
			au2.play();
	}
}


