FileDocCategorySizeDatePackage
SoundPlay.javaAPI DocExample881Sat Nov 25 12:55:10 GMT 2000None

SoundPlay

public class SoundPlay extends Object
Simple program to try out the "new Sound" stuff in JDK1.2 -- allows Applications, not just Applets, to play Sound.

Fields Summary
static String[]
defSounds
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] av)

	     
		if (av.length == 0)
			main(defSounds);
		else for (int i=0;i<av.length; i++) {
			System.out.println("Starting " + av[i]);
			try {
				URL snd = new URL(av[i]);
				// open to see if works or throws exception, close to free fd's
				// snd.openConnection().getInputStream().close();
				Applet.newAudioClip(snd).play();
			} catch (Exception e) {
				System.err.println(e);
			}
	 	}
		// With this call, program exits before/during play.
		// Without it, on some versions, program hangs forever after play.
		// System.exit(0);