add Sound in to Thread #5
|
@ -7,9 +7,9 @@ public class HalloSchiffeVersenken {
|
||||||
|
|
||||||
System.out.println("sound");
|
System.out.println("sound");
|
||||||
SoundHandler.playSound("hit");
|
SoundHandler.playSound("hit");
|
||||||
Thread.sleep(3000);
|
|
||||||
System.out.println("sound");
|
Thread.sleep(10000);
|
||||||
SoundHandler.playSound("hit");
|
|
||||||
SoundHandler.setSoundOn(false);
|
SoundHandler.setSoundOn(false);
|
||||||
System.out.println("sound off");
|
System.out.println("sound off");
|
||||||
SoundHandler.playSound("hit");
|
SoundHandler.playSound("hit");
|
||||||
|
|
|
@ -16,16 +16,22 @@ public class SoundHandler {
|
||||||
|
|
||||||
public static void playSound(String soundName) {
|
public static void playSound(String soundName) {
|
||||||
if (soundOn) {
|
if (soundOn) {
|
||||||
try {
|
new Thread(new Runnable() {
|
||||||
Player player = new Player(new FileInputStream(sounds.get(soundName)));
|
@Override
|
||||||
player.play();
|
public void run() {
|
||||||
} catch (JavaLayerException | FileNotFoundException e) {
|
try {
|
||||||
System.out.println("dslkfsfnsldfnlsnfsdnölscls");
|
Player player = new Player(new FileInputStream(sounds.get(soundName)));
|
||||||
e.printStackTrace();
|
player.play();
|
||||||
}
|
} catch (JavaLayerException | FileNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void add(String soundName, String path){
|
static void add(String soundName, String path){
|
||||||
sounds.put(soundName, path);
|
sounds.put(soundName, path);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue