I know this is an already asked question, but i cant get no answer
i found this way to play the sound:
Clip sound = AudioSystem.getClip(); sound.open(AudioSystem.getAudioInputStream(new File("path/to/sound"))); sound.start(); but the problem is i run this code in a gameloop, and i would like to structure it in a way so that i dont need to read the sound from input each time, but already have saved the sound in the memory so i dont have to load it everytime.
i tried doing something like this:
Clip sound = AudioSystem.getClip(); sound.open(AudioSystem.getAudioInputStream(new File("path/to/sound"))); while(true) { sound.start(); } also like this
AudioStream audiostream = AudioSystem.getAudioInputStream(new File("path/to/sound")); while(true) { Clip sound = AudioSystem.getClip(); sound.open(AudioSystem.getAudioInputStream(audiostream)); sound.start(); } but it doesnt work, or it works only 1 time