I am working on a program that needs to play a sound Clip and it doesn't work on XP but it does on OS/X.
I've reduced the problem to this simple test program. On my PC, the sound I hear on the speakers is just a little burst of noise, whereas it's fine on my Mac. I used one of XP's system wav files, and verified that it does play normally on the PC via other means (iTunes, etc.). I'm using the latest JDK/JRE everywhere. Here's the sample code. Anything obviously wrong here?
import java.io.*;
import javax.sound.sampled.*;
class ClipTest
{
public static void main(String args[])
{
try
{
Clip soundClip;
AudioInputStream soundStream;
File audioFile = new File("CHIMES.WAV");
soundStream = AudioSystem.getAudioInputStream(audioFile);
AudioFormat format = soundStream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
System.out.println(format.toString());
soundClip = (Clip)AudioSystem.getLine(info);
soundClip.open(soundStream);
soundClip.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}