I am tyring to write some Java code that basically just plays a short .wav file - with \'short\' I mean a fraction of a second. (The file I use is at /usr/share/sounds/gener
I have had good luck using the following code in an application (even though it uses the Applet's newAudioClip() method):
AudioClip clip;
File fileClip = new File("/usr/share/sounds/generic.wav");
URL url = null;
try
{
URI uri = fileClip.toURI();
url = uri.toURL();
clip = Applet.newAudioClip(url);
}
catch (MalformedURLException e){}
clip.play();
I got this method from: Starting Out with Java: From Control Structures Through Objects, 4th Edition by Tony Gaddis, Addison Wesley, ISBN-13 978-0-13-608020-6