Play a wav. file

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 33
Reputation: AlbertPi is an unknown quantity at this point 
Solved Threads: 2
AlbertPi AlbertPi is offline Offline
Light Poster

Play a wav. file

 
0
  #1
Nov 19th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum


Views: 961 | Replies: 0
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC