Closing out of a wav file in a GUI
Hello. I have created a GUI that plays a .wav file. Does anyone know of a simple command to close all files outside of a GUI or to simply reset the entire program to the beginning stage? Here is the code I use to run my song : public void songEngine(){
try {
File yourFile = new File(string);
AudioFormat format;
DataLine.Info info;
Clip clip;
stream = AudioSystem.getAudioInputStream(yourFile);
format = stream.getFormat();
info = new DataLine.Info(Clip.class, format);
clip = (Clip) AudioSystem.getLine(info);
clip.open(stream);
clip.start();
}
catch (Exception e1) {
//whatevers
}
}
}
The button used to stop is an Action listener. So I would need to implement that.
Re: Closing out of a wav file in a GUI
Quote:
Originally Posted by
cocomojoe81
The button used to stop is an Action listener. So I would need to implement that.
How to Write an Action Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
Re: Closing out of a wav file in a GUI
I know how to do the Action Listener, I just don't know how to stop the file from playing.
Re: Closing out of a wav file in a GUI