All I want is to get this into a Jar working, no problems in Eclipse, but jar does not play music. I tried several "solutions" from google and stackoverflow.
class Soundboard implements ActionListener {
public Soundboard() {
}
@Override
public void actionPerformed(ActionEvent ev) {
if (ev.getSource() instanceof JButton) {
JButton b = (JButton) ev.getSource();
// getClass().getSystemResource("images/SomeImage.png")
String build = "sound/" + b.getText() + ".au";
try {
playMusic(new File(build));
} catch (UnsupportedAudioFileException | IOException
| LineUnavailableException e) {
e.printStackTrace();
}
}
}
private void playMusic(File file) throws UnsupportedAudioFileException,
IOException, LineUnavailableException {
AudioInputStream stream = AudioSystem.getAudioInputStream(file);
AudioFormat format = stream.getFormat();
DataLine.Info info = new DataLine.Info(Clip.class, format);
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(stream);
clip.start();
}
}