Play a wav. file
Please support our Java advertiser: Programming Forums
![]() |
•
•
Posts: 27
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
Other Threads in the Java Forum
- 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)
- help executing a .wav file with php code (PHP)
Other Threads in the Java Forum
- Previous Thread: Recursively reverse an array
- Next Thread: calling a function very basic >>> <<<<
•
•
•
•
Views: 508 | Replies: 0 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode