Found this sniplet of code on various websites to use this way of playing a wav file however im getting this error message.
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file
Update 1 - I know the wav file has to be 8khz, is there a way to convert any wav file to 8khz?
static class addAudioAction implements ActionListener {
public void actionPerformed(ActionEvent e) {
playWave();
}
}
static void playWave() {
try {
AudioInputStream audioInputStream;
File file = new File("test.wav");
audioInputStream = AudioSystem.getAudioInputStream(file);
Clip line;
line = (Clip) AudioSystem.getLine(new DataLine.Info(Clip.class, audioInputStream.getFormat()));
line.open(audioInputStream);
line.start();
line.drain();
audioInputStream.close();
}
catch (Exception e)
{
e.printStackTrace();
}
Toolkit.getDefaultToolkit().beep();
}