Hello I am trying to add music into my java game, but the problem I have is that when I call the class using "new music ();". And the music starts playing but the rest of the game wont work until the...

Hello I am trying to add music into my java game, but the problem I have is that when I call the class using "new music ();". And the music starts playing but the rest of the game wont work until the song ends. Can you help me with getting the song to play in the background without stoping the game. Here is my music code: import java.io.File; import javax.sound.sampled.*; public class Music { public Music() { try{ AudioInputStream ais = AudioSystem.getAudioInputStream(new File("TT.wav")); Clip test = AudioSystem.getClip(); test.open(ais); test.start(); while (!test.isRunning()) Thread.sleep(10); while (test.isRunning()) Thread.sleep(10); test.close(); }catch(Exception ex){ ex.printStackTrace(); } } }

May 19, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here