Answers for "how to play audio files java"

0

how to play audio files java

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();
Posted by: Guest on July-05-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language