📅  最后修改于: 2022-03-11 14:52:40.438000             🧑  作者: Mango
File audioFile = new File("ur file's path").getAbsoluteFile();
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(audioFile);
Clip clip = AudioSystem.getClip();
clip.open(audioInputStream);
//Plays audio once
clip.start();
//Plays the audio in a loop
clip.loop(Clip.LOOP_CONTINUOUSLY);
//Stop the audio
clip.stop();
//optional
clip.close();