how to play a clip of audio in java when needed
Clip clip;
try {
AudioInputStream input=AudioSystem.getAudioInputStream(new File("audio.wav"));
clip=AudioSystem.getClip();
clip.open(input);
clip.start();
} catch (UnsupportedAudioFileException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (LineUnavailableException e) {
e.printStackTrace();
}AudioInputStream input = new AudioInputStream(Path_to_the_file);
Clip clip=AudioSystem.geClip();
clip.open(input);
Clip.loop(Clip.LOOP_CONTINUOSLY);
clip.start();
Also in Java:
- properties java 8 maven in pom xml
- java print syntax
- insert element into arraylist java
- Java how to copy file
- how to change the color of a menubar in java
- change brightness of image in java
- arrays.aslist.add
- java script removing first three indexes
- write file java
- count occurrences of character in string java 8
- java string is null or empty
- unity how to make a gameobject slowly look at a position
- java string to double
- split every character in string into array java
- spigot actionbar
- how to create a circle in java
- java round double to 2 decimal places
- java android edit text set value
- set java
- floor in java
- vertical traversal of binary tree
- how to minimize jframe in java
- java iterate over list
- bootstrap center text vertically