我正在尝试用 Java 创建一个媒体播放器。我已经创建了 GUI,现在我需要加载一首歌曲。我使用了 AudioPlayer,但它不起作用。这是代码:
AudioPlayer audioP = AudioPlayer.player;
AudioStream audioS;
AudioData audioD;
ContinuousAudioDataStream loop = null;
audioS = new AudioStream(new FileInputStream("file:TheDragonBornComes.wav"));
audioD = audioS.getData();
loop = new ContinuousAudioDataStream(audioD);
audioP.start(loop);
错误是:
Exception in thread "main" java.io.FileNotFoundException: file:TheDragonBornComes.wav
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:138)
at java.io.FileInputStream.<init>(FileInputStream.java:97)
at medalmedia.MedalMedia.main(MedalMedia.java:26)
编辑:我已经更改了文件的位置,最后一个错误已经解决。但是,有一个新的:
Exception in thread "main" java.io.IOException: could not create AudioData object