i've tried dozens of tutorials haven't been able of them working. want .wav file play in background of application.
see: how play .wav file jbutton?
public void playsound(string soundname) { try { audioinputstream audioinputstream = audiosystem.getaudioinputstream(new file(soundname).getabsolutefile()); clip clip = audiosystem.getclip(); clip.open(audioinputstream); clip.start(); } catch(exception ex) { system.out.println("error playing sound."); ex.printstacktrace( ); } }
Comments
Post a Comment