嗯,具体来说,为什么这里的代码似乎不想播放第二个音频文件:
public static void main(String[] args) {
//Plays first file for a few seconds
playMusic(new File("C:\\sample.wav"));
wait(5.0);
System.out.print("...");
//Second file that doesn't want to play:
playMusic(new File("C:\\sample2.wav"));
}
public static void playMusic(File Stream) {
AudioInputStream AIS
= AudioSystem.getAudioInputStream(Stream);
Clip music = AudioSystem.getClip();
music.open(AIS);
music.start();
}
我想我必须解雇某些东西(例如music.close(),AIS.close()),但这些特定的例子似乎没有任何效果。有什么想法吗?