audio - How to play external sound file in Java -
how play sound in java not internally saved in java project? have tried code work file compiled in java project.. want make sound file directory apart java project.
private void sound (int s) { try { clip clip = audiosystem.getclip(); audioinputstream inputstream = audiosystem.getaudioinputstream(main.class.getresourceasstream("music/sound"+s+".wav")); clip.open(inputstream); clip.start(); } catch (lineunavailableexception | unsupportedaudiofileexception | ioexception e) { system.err.println(e.getmessage()); } }
Comments
Post a Comment