Hello, i got some trouble with using Sounds in java. I just wanted to implement some fancy 8 bit sounds to my newest retro 2d game.... when i run it in java eclipse everything is fine and the sounds work....
but as soon as i run the finished application (the application itself works perfect...) but the sounds wont play and there is the error you can see in the 3d picture.
picture 1 shows my "sound method" and picture 2 how i use it.
How could i fix this?
I found the solution. I changed the code of my audio method slightly.... and for some reason it works now. here's the code of it.
public void playSound(String soundFile) {
try {
AudioInputStream audioIn = AudioSystem.getAudioInputStream(this.getClass().getResource("/Sounds/" + soundFile));
Clip clip = AudioSystem.getClip();
clip.open(audioIn);
clip.start();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}
}