try //playing the music
{
String soundName = "yourAudioFile.wav";
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File(soundName).getAbsoluteFile());
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
clip.start(); //start to play the clip
}
catch (Exception e)
{
//Do stuff in case of an exception, for example, file not found
}
# 1 楼答案
进口:
代码: