java桌面游戏怎么加背景音乐
1个回答
展开全部
try {
URL musicUrl = new URL("file:" + System.getProperty("user.dir").toString() + "\\src\\because.mp3");
System.out.println(System.getProperty("user.dir").toString() + "\\src\\because.mp3");
AudioClip ac = Applet.newAudioClip(musicUrl);
ac.play();
}
catch (MalformedURLException e) {
e.printStackTrace();
}
URL musicUrl = new URL("file:" + System.getProperty("user.dir").toString() + "\\src\\because.mp3");
System.out.println(System.getProperty("user.dir").toString() + "\\src\\because.mp3");
AudioClip ac = Applet.newAudioClip(musicUrl);
ac.play();
}
catch (MalformedURLException e) {
e.printStackTrace();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询