Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

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();
 
PREVIOUS NEXT
Tagged: #play #audio #files #java
ADD COMMENT
Topic
Name
5+8 =