Hey Folks!
I created a little Java Game and now i want to include Sound.
I created a Sound Class:
package game;
import java.applet.Applet;
import java.applet.AudioClip;
public class Musik {
public static final Musik musik1 = new Musik("/src/game/Sound/Test.wav");
private AudioClip clip;
public Musik(String filename){
try{
clip = Applet.newAudioClip(Sound.class.getResource(filename));
}catch(Exception e){
e.printStackTrace();
}
}
public void play(){
try{
new Thread(){
public void run(){
clip.play();
}
}.start();
}catch(Exception ex){
ex.printStackTrace();
}
}
}
and then in my gameFrame Class i put this:
private Musik musik1;
public void init() {
Musik.musik1.play();
}
But nothing happens, where is the problem? There is no sound playing, neither in the Menu where I select “Play Game” nor in the Game itself.
I got this Code from a Tutorial on Youtube,
I hope some1 can help me!
greez