這裏夾線就是我using.I已經使用裁剪類發揮clip.Program已經沒有任何錯誤的編譯和運行正常,但我不能聽到聲音的代碼。的java:不工作
import java.io.File;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
public class ClipTest {
public static void main(String[] args) throws Exception {
File soundFile = new File("./1.wav");
AudioInputStream sound = AudioSystem.getAudioInputStream(soundFile);
DataLine.Info info = new DataLine.Info(Clip.class, sound.getFormat());
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(sound);
clip.addLineListener(new LineListener() {
public void update(LineEvent event) {
if (event.getType() == LineEvent.Type.STOP) {
event.getLine().close();
System.exit(0);
}
}
});
clip.start();
}
}
請有看看我的帖子。它在我的機器 – 2013-02-09 08:49:57