play a audion clip by java swing code example
Example: 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();
}