0
How to add music in java game?
Do anyone of you guys know how to add music whenever game loads and button pressed please tell?
1 Odpowiedź
+ 1
In javaFX there are MediaPlayer
Or you can smth like this
File soundFile = new File("snd.wav");
AudioInputStream ais = AudioSystem.getAudioInputStream(soundFile);
Clip clip = AudioSystem.getClip();
clip.open(ais);
clip.setFramePosition(0);
clip.start(); Thread.sleep(clip.getMicrosecondLength()/1000);
clip.stop();
clip.close();