how to use a wav file in eclipse

Posted by AlphaAndOmega on Stack Overflow See other posts from Stack Overflow or by AlphaAndOmega
Published on 2011-11-27T01:43:55Z Indexed on 2011/11/27 1:50 UTC
Read the original article Hit count: 167

Filed under:
|
|

I've been trying to add audio to a project I've been doing. I found some code on here for html that is also supposed to work with file but it keeps saying

"Exception in thread "main" javax.sound.sampled.UnsupportedAudioFileException: could not get audio input stream from input file at javax.sound.sampled.AudioSystem.getAudioInputStream(Unknown Source) at LoopSound.main(LoopSound.java:15)" the code

public class LoopSound {

public static void main(String[] args) throws Throwable  {
    File file = new File("c:\\Users\\rabidbun\\Pictures\\10177-m-001.wav");
    Clip clip = AudioSystem.getClip();
    // getAudioInputStream() also accepts a File or InputStream
    AudioInputStream wav = AudioSystem.getAudioInputStream( file );
    clip.open(wav);
    // loop continuously
    clip.loop(-1000);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            // A GUI element to prevent the Clip's daemon Thread
            // from terminating at the end of the main()
            JOptionPane.showMessageDialog(null, "Close to exit!");
        }
    });
}

}

What is wrong with the code?

© Stack Overflow or respective owner

Related posts about java

Related posts about eclipse