| | |
Play a wav. file
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 33
Reputation:
Solved Threads: 2
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.
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
- help executing a .wav file with php code (PHP)
- How do I play a .wav file from Resources? (VB.NET)
- Play a .wav file (Java)
- how to play wav file (Visual Basic 4 / 5 / 6)
- how to play wav file (Visual Basic 4 / 5 / 6)
- play .wav file with data (Visual Basic 4 / 5 / 6)
- .wav file on x86 (Assembly)
Other Threads in the Java Forum
- Previous Thread: Recursively reverse an array
- Next Thread: calling a function very basic >>> <<<<
Views: 961 | Replies: 0
| Thread Tools | Search this Thread |
Tag cloud for Java
account android api apple applet application arguments array arrays automation binary bluetooth chat class classes client code columns component data database draw eclipse error event exception expand file filechooser fractal game givemetehcodez google graphics gui helpwithhomework homework html ide image inheritance input integer j2me java javaprojects jlabel jme jmf jni jpanel jtextfield julia linux list loop map method methods midlethttpconnection mobile monitoring netbeans newbie nullpointerexception number object open-source oracle print problem program programming project property recursion ria scanner screen search server set size sms socket sort sourcelabs splash sql sqlite static string swing test testautomation threads time transfer tree windows





