music loop java

Solutions on MaxInterview for music loop java by the best coders in the world

showing results for - "music loop java"
Honour
08 Jan 2021
1// Makes a music loop
2Thread music = new Thread() {
3	public void run() {
4		Clip clip;
5		try {
6			AudioInputStream input = AudioSystem.getAudioInputStream(new File("music.wav"));
7			clip = AudioSystem.getClip();
8			clip.open(input);
9			clip.loop(Clip.LOOP_CONTINUOUSLY);
10			clip.start();
11		} catch (UnsupportedAudioFileException e) {
12			e.printStackTrace();
13		} catch (IOException e) {
14			e.printStackTrace();
15		} catch (LineUnavailableException e) {
16			e.printStackTrace();
17		}
18	}
19};
20music.start();