DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Java (http://www.daniweb.com/forums/forum9.html)
-   -   Play a wav. file (http://www.daniweb.com/forums/thread158338.html)

AlbertPi Nov 19th, 2008 12:24 pm
Play a wav. file
 
This is my function. see below:
public void SoundTest() {
try {
AudioInputStream audioInputStream;
File file = new File("C:\\Temp\\online.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();
}

I got this error when I ran it:
javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file.
Need help about "could not get audio input stream from input file". also I can play this .wav file from real player and Windows media play. Thanks.


All times are GMT -4. The time now is 10:25 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC