아마도이 방법은 잘못 접근하고 있지만 루핑 된 javax.sound.sampled 클립을 중지하는 방법을 찾아야합니다. 9 가지 소리가 난다. 사용자가 진폭 증가 버튼을 누르면 다른 소리가 재생되기를 원합니다. 지금은 버튼을 클릭 할 때마다 playSound 메서드를 호출하고 작동하지만 이미 재생중인 소리는 멈추지 않습니다. 소리가 서로 연주됩니다.루핑 javax.sound.sampled 클립 닫기
사용자가 버튼을 누를 때 기존 사운드를 모두 닫을 수 있습니까?
여기 내 꺼내, 코드입니다 :
public void playSound(){
try {
audio = AudioSystem.getAudioInputStream(soundFile[activeSound]);
clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
clip.loop(Clip.LOOP_CONTINUOUSLY);
}
catch (IOException ex){
System.out.println("Sorry but there has been a problem reading your file.");
ex.printStackTrace();
}
catch (UnsupportedAudioFileException ex1){
System.out.println("Sorry but the audio file format you are using is not supported.");
ex1.printStackTrace();
}
catch (LineUnavailableException ex2){
System.out.println("Sorry but there are audio line problems.");
ex2.printStackTrace();
}
}
지금 이틀 동안이에서 봤는데 그 미친 날 운전입니다. 어떤 도움이라도 대단히 감사 할 것입니다.
멋진 예외 처리. +1 또한 SO에 오신 것을 환영합니다. :) –