Hello I have a programme with a title screen. I want there to be title music. I have a music file already created and it is about 10 seconds long. I want it to keep repeating when it finishes:
Here is my sound class:
public class Sound {
public static final Sound cash = new Sound("/cash.wav");
public static final Sound snap = new Sound("/snap.wav");
public static final Sound disarm = new Sound("/disarm.wav");
public static final Sound tp = new Sound("/tp.wav");
public static final Sound select = new Sound("/selectBTN.wav");
public static final Sound scroll = new Sound("/btn.wav");
public static final Sound fire = new Sound("/fire2.wav");
public static final Sound titlemusic = new Sound("/music/TitleMusic.wav");
private AudioClip c;
public Sound(String filename) {
try {
c = Applet.newAudioClip(Sound.class.getResource(filename));
} catch (Exception e) {
e.printStackTrace();
}
}
public void play() {
try {
new Thread() {
public void run() {
if (!title.mute) {
c.play();
}
}
}.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}
and I tell it to play a sound like this when I want to play it:
Sound.titlemusic.play();
Please help me. Thx
Aucun commentaire:
Enregistrer un commentaire