私は友人のために、彼の面白い写真を見せて音をループさせる基本的なプログラムを作っています。JAR をエクスポートしてもうまくいかなかったので、WinRar で JAR を開きました。ファイルはそこにありましたが、再生されませんでした。
コード:
//imports
public class twerk {
static File fl = new File("res//sounds//liver.au");
static int loo = 1;
static JFrame frame = new JFrame("COLLIN");
public static void frame(){
frame.setSize(1086,800);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
ImageIcon image = new ImageIcon("res//images//collin.jpg");
JLabel label = new JLabel(image);
frame.add(label, BorderLayout.NORTH);
frame.setIconImage(image.getImage());
frame.setVisible(true);
try
{
String st =fl.getPath();
InputStream in = new FileInputStream(st);
AudioStream au = new AudioStream(in);
AudioPlayer.player.start(au);
if(loo == 1){
Thread.sleep(1900);
frame();
}
} catch(Exception e){}
}
public static void main(String[] args){
frame();
}
}
WinRar で開いた JAR ファイルの画像
画像とサウンドのフォルダーが jar ファイルにあることがわかりますが、それらは使用されていません。