0
에서 멈 춥니 다. 특정 사운드를 재생하는 Java 클래스를 만들려고 시도하지만 사운드는 끝이 아닌 임의의 순간에 중단됩니다. 왜 그 일을하는거야? 미리 감사드립니다!.wav 파일의 사운드가 임의의 시간에 JAVA
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
public class CoreJavaSound extends Object implements LineListener {
File soundFile;
JDialog playingDialog;
Clip clip;
public static void main(String[] args) throws Exception {
PlayBow();
}
public CoreJavaSound(String fileName) throws Exception {
JFileChooser chooser = new JFileChooser();
soundFile = new File(fileName);
System.out.println("Playing " + soundFile.getName());
Line.Info linfo = new Line.Info(Clip.class);
Line line = AudioSystem.getLine(linfo);
clip = (Clip) line;
clip.addLineListener(this);
AudioInputStream ais = AudioSystem.getAudioInputStream(soundFile);
clip.open(ais);
clip.start();
}
@Override
public void update(LineEvent le) {
LineEvent.Type type = le.getType();
if (type == LineEvent.Type.OPEN) {
System.out.println("OPEN");
} else if (type == LineEvent.Type.CLOSE) {
System.out.println("CLOSE");
System.exit(0);
} else if (type == LineEvent.Type.START) {
System.out.println("START");
playingDialog.setVisible(true);
} else if (type == LineEvent.Type.STOP) {
System.out.println("STOP");
playingDialog.setVisible(false);
clip.close();
}
}
public static void PlayBow() throws Exception
{
CoreJavaSound s = new CoreJavaSound("Bow.wav");
}
}
모든 사운드가 (파일 5 초 동안) 일초와 같은 후 작동을 멈 춥니 다한다는 사실을 제외하고 잘 작동 ...
위대한 작품! 그래서 나는 그것에 대해 생각하지 말고 멍청하다 : p 대단히 감사합니다! –