聲音,當我運行JAR不玩了,但它確實當我在Eclipse中運行它。音頻不會在罐發揮,但確實在Eclipse
這裏就是我加載剪輯:
public void init(){
System.out.println("grabbing Music");
String currentDir = new File("").getAbsolutePath();
name=new File(currentDir+"\\music\\").list();
clip=new Clip[name.length];
soundFile=new File[name.length];
for(int x=0;x<name.length;x++){
System.out.println(currentDir+"\\music\\"+name[x]);
try {
soundFile[x]= new File(currentDir+"\\music\\"+name[x]);
AudioInputStream sound = AudioSystem.getAudioInputStream(soundFile[x]);
DataLine.Info info= new DataLine.Info(Clip.class, sound.getFormat());
clip[x] = (Clip) AudioSystem.getLine(info);
clip[x].open(sound);
clip[x].addLineListener(new LineListener(){
public void update(LineEvent event) {
if (event.getType() == LineEvent.Type.STOP) {
event.getLine().close();
}
}
});
} catch (LineUnavailableException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
}
}
}
在Eclipse中運行它時我沒有得到任何錯誤。不應該有一個無效的目錄錯誤的可能性,所以什麼是錯的?
- 當瓶子在CMD運行我沒有得到任何錯誤。
編輯:我覺得我加載音頻錯誤的,因此爲什麼我貼我用來加載的文件中的代碼在我的搜索我還沒有看到任何人使用文件的聲音文件中加載。不知道這是否是問題?
是進入我的腦海
請打印堆棧跟蹤。 – Azad
沒有錯誤引發。它只是不玩。 – lifedistroy
你如何檢查錯誤? –