// File PlaySound.java
// Tim Balls : Jan 2000
// Play sounds from an application
// use: java PlaySound filename
import java.applet.*;
import java.net.*;
public class PlaySound
{ public static void main( String[] args ) throws Exception
{ URL url = new URL( "file:" + System.getProperty( "user.dir" )
+ System.getProperty( "file.separator" ) + args[0] );
System.out.println( "Playing : " + url );
AudioClip au = Applet.newAudioClip( url );
au.play();
Thread.sleep(10000);
}
} |