943,703 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 2235
  • Java RSS
Nov 19th, 2008
0

Play a wav. file

Expand Post »
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.
Similar Threads
Reputation Points: 9
Solved Threads: 2
Light Poster
AlbertPi is offline Offline
33 posts
since Nov 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Recursively reverse an array
Next Thread in Java Forum Timeline: calling a function very basic >>> <<<<





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC