1
안녕하세요. 내 응용 프로그램에 적합한 사운드 클래스가 있으며, 내가 말할 때 특정 사운드를 재생합니다.Java 소리 감지시 감지하기
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");
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();
}
}
}
후 내가 사용하는 사운드를 재생 : 나는 소리가 그래서 여기에 래핑을 통해 그들없이 다른 사운드를 재생할 수있는 재생 완료 될 때 감지 할 수 있기를 원하는 것은 내 사운드 클래스 이 코드 줄 : 사운드가이 같은 (AN aproximation이다)를 시도
이 작동하지만 몇 가지 이유에 대해 한 번 내가이 – user2279603
그것의이 같은 사운드 객체를 재사용 할 것으로 보인다 해결할 수있는 방법은 늘 다시 재생 사운드를 재생, 참조 http://stackoverflow.com/questions/9999961/song-plays-first-time-but-not-play-once-stopped-clip-in-java – rafalopez79