I have this slightly altered a sound manager from another question How can I play sound in Java?. Here it is:
public static synchronized void playSound(final String url)
{
new Thread(new Runnable()
{
public void run()
{
try
{
Clip clip = AudioSystem.getClip();
AudioInputStream inputStream = AudioSystem.getAudioInputStream(new File("sound/" + url));
clip.open(inputStream);
clip.start();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}).start();
}
Whenever I call this method I get a javax.sound.sampled.LineUnavailableException in the clip.open(inputStream);
. What can I do to repair it? Why does it not work?
playSound("songs/Song3.wav");
. It exists and is there. – rdelfin Mar 15 '12 at 16:03