Reputation: 75
Well, specifically, why this code here doesn't seem to want to play the second audio file:
public static void main(String[] args) {
//Plays first file for a few seconds
playMusic(new File("C:\\sample.wav"));
wait(5.0);
System.out.print("...");
//Second file that doesn't want to play:
playMusic(new File("C:\\sample2.wav"));
}
public static void playMusic(File Stream) {
AudioInputStream AIS
= AudioSystem.getAudioInputStream(Stream);
Clip music = AudioSystem.getClip();
music.open(AIS);
music.start();
}
I figure I have to dismiss something or other (e.g. music.close(), AIS.close()), but these particular examples don't seem to have any effect. Any ideas?
Upvotes: 2
Views: 518
Reputation: 7285
Is it possible your application terminates before your audio clip has finished playing? You may find this SO answer helpful.
Upvotes: 1