Java how to stop audio
hello
i have this code in the main:
try {
AudioInputStream audio = AudioSystem.getAudioInputStream(new File("x.wav"));
Clip clip = AudioSystem.getClip();
clip.open(audio);
clip.start();
}
catch(UnsupportedAudioFileException uae) {
System.out.println(uae);
}
catch(IOException ioe) {
System.out.println(ioe);
}
catch(LineUnavailableException lua) {
System.out.println(lua);
}
I want that when i press the stop button in the gui, the audio stops... please tell me what should i write in the action listener for the button
when i write clip.close(); it shows error
please help
View Answers
June 15, 2011 at 4:59 PM
Use the following code:
JButton button=new JButton("Stop");
button.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
clip.stop();
}
});
For the above,you need to import java.awt.event.* package
June 17, 2011 at 8:04 PM
that is fine
but when i add the clip.stop(); it shows an eexception it thread error... in Netbeans.. it says" cannot find variable clip, create class clip , create field clip.... what should i do?
Ads
Related Tutorials/Questions & Answers:
Java how to stop audio
Java how to
stop audio hello
i have this code in the main:
try {
AudioInputStream
audio = AudioSystem.getAudioInputStream(new File...);
}
I want that when i press the
stop button in the gui, the
audio stops
how to stop audio (mp3)
how to
stop audio (mp3)
if(e.getActionCommand().
equals("
Stop")){
player.stop();
}
i am making an
audio player in which i... stopping it.
how should i
stop the song keeping in mind i have to play another song
Advertisements
how to play audio track in java applat
how to play
audio track in
java applat Sir,i took help of coding in
how to play
audio track in
java applet....nd i found perfect code ..but when i... file...as u see there is no main claas in this coding then
how would i run dis
how to solve 'Stop Running This Script' Error ?
how to solve '
Stop Running This Script' Error ? Hi..
When opened the page on IE browser(version : 8.0),it gives an
java script error (i.e.Stop Running This Script).
I have used jsp/servlet for this.
Please help to resolved
Java Thread : stop() method
Java Thread :
stop() method
In this section we are going to describe
stop() method with example in
java thread.
stop() method :
Java thread provides method
stop to
stop any running thread. It is
deprecated as it causes
how to add audio clip in swings with event handling
how to add
audio clip in swings with event handling hello dear, i wanna to play
audio clip in
java program in JFrame in swings by event handling ,it should be like when i click on a button ,
audio clip should play , plz tell me
Play Audio in Java Applet
the sound file. This program will show
you
how to play a
audio clip in your
java applet...
Play
Audio in
Java Applet
 ... is used to
play the sound while
stop() method is used for
stop the running
audio
How to Remove audio from video file with FFmpeg?
How to Remove
audio from video file with FFmpeg? I have a video... in video.
How to remove
audio from video file with FFmpeg?
thanks
Hi,
You can use the '-an' option to remove the
audio from video.
Check
stop repetition
stop repetition i want to know use of Hashmap, and its contains key... record more than one time. so could u please guide me
how to handle this problem... they have same id so i want to
stop repetition
ModuleNotFoundError: No module named 'stop'
ModuleNotFoundError: No module named '
stop' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
stop'
How to remove the ModuleNotFoundError: No module named '
stop' error
Audio Processing
Audio Processing Sir, I want implement an
audio recognition system by using
java.. Is it possible? and tell me the process...
thank you
stop the running hidden server
will need to
stop the other process or change the port number(s).
how to
stop tis...
stop the running hidden server Port 8080 required by Tomcat v6.0 Server at localhost is already in use. The server may already be running in another
ModuleNotFoundError: No module named 'stop-words'
'
stop-words'
How to remove the ModuleNotFoundError: No module named '
stop...ModuleNotFoundError: No module named '
stop-words' Hi,
My Python... have to install padas library.
You can install
stop-words python
playing an audio file
how to solve this problem and also tell me where i should pass my
audio clip path
Please visit the following link:
http://www.roseindia.net/
java...playing an
audio file In playing an
audio file we have to take one
ModuleNotFoundError: No module named 'audio'
ModuleNotFoundError: No module named '
audio' Hi,
My Python program is throwing following error:
ModuleNotFoundError: No module named '
audio'
How to remove the ModuleNotFoundError: No module named '
audio'
Audio Level Meter
Audio Level Meter Hello
I'm new to programming and I'm trying to make a
java application that will "hear" (not record necessarily) the sound and display
how loud is.I'm thinking of converting the sound recordings to numbers,so
HTML5 audio reference
HTML5
audio reference Hi,
Tell me the best url to learn HTML5
audio tags with examples.
Thanks
Hi,
Learn
how to use HTML5
audio tags to play the
audio on web page. The HTML5
audio tag is used to play the video