I'm trying to make a very simple program to play a sound file.
So far all I have is:
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
public class SoundTest {
public static void main(String[] args) {
File sound = new File("/home/pierce/Downloads/clapping.wav");
playSound(sound);
}
static void playSound(File sound) {
try {
Clip clip = AudioSystem.getClip();
clip.open(AudioSystem.getAudioInputStream(sound));
} catch(Exception e) {
System.out.println("Something failed");
}
}
}
After adding the line "clip.open(AudioSystem.getAudioInputStream(sound));", I started getting the message in the exception. Basically I have no idea why. Any help would be appreciated.
If it helps to see what I'm aiming at, I'm trying to follow this tutorial.
Thanks
Edit: Stack trace, as requested:
java.lang.IllegalArgumentException: Invalid format
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.createStream(PulseAudioDataLine.java:142)
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:99)
at org.classpath.icedtea.pulseaudio.PulseAudioDataLine.open(PulseAudioDataLine.java:283)
at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:402)
at org.classpath.icedtea.pulseaudio.PulseAudioClip.open(PulseAudioClip.java:453)
at SoundTest.playSound(SoundTest.java:17)
at SoundTest.main(SoundTest.java:10)