我正试图让这个程序无限循环播放这首歌,但我只是设法让它工作一次。有什么建议吗?
这是我的代码:
public static void music(){
String filename = "darkAura.wav";
ContinuousAudioDataStream loop = null;
InputStream in = null;
try {
in = new FileInputStream(filename);
} catch (FileNotFoundException ex) {
System.out.println("File not found");
}
try {
AudioStream s = new AudioStream(in);
AudioData MD;
AudioPlayer.player.start(s);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
答案 0 :(得分:2)
您根本没有使用loop
变量。
试试这样:
AudioStream s = new AudioStream(in);
AudioData audiodata = s.getData();
loop = new ContinuousAudioDataStream(audiodata);
AudioPlayer.player.start(loop);