Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners Java how to stop audio

Have Programming Question? Ask it here!
 
 
 


Karan Dwivedi
Java how to stop audio
2 Answer(s)      3 years and 2 months ago
Posted in : Java Beginners


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


Advertisement
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?



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 allow or stop using internet - Java Server Faces Questions
how to allow or stop using internet  hello this is my first qusetion I am developing a cybercafe management tool in java,the problem is how to allow or stop the users of cafe using internet by the administrator on other
How to stop the execution of midlet in j2me?
How to stop the execution of midlet in j2me?  Hi, How to stop the execution of midlet of j2me for a specific amount of time? Thanks & Regards, Sivakumar.J
How to stop java scripting engine when the script being run is taking too much time?
How to stop java scripting engine when the script being run is taking too much time?   How to stop java scripting engine when the script being run is taking too much time? for e,g, in case of infinite loop the memory is getting
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
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 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
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
stop an infinite for loop - Java Beginners
stop an infinite for loop  class InfiniteForLoop{ public static void main(String[] args) { for(;;){ } } } i want this infinite for loop program to be stopped by another program named kill
Need simple java code to start and stop the remote windows service.
Need simple java code to start and stop the remote windows service.  Hi, I Need simple java code to start and stop the remote windows service. Example:There are two servers 1) Server A and 2) Server B. If a notepad.exe file
how to run audio files in net beans using j2me
how to run audio files in net beans using j2me  i am running the audioMidlet in net beans. Now where should i place the .wav files inorder to play them
java code to display in audio - Java Beginners
java code to display in audio  Is their any java code, When i enterd text in text field , and when i press submit button,the text i entered should come in voice  Hi friend, Code to help in solving the problem
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
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
Audio
an applet and from an application. Where to learn about Java audio A good way to learn about audio is to read the "Sound" section of the Java Tutorial (see Other... Java NotesAudio Java 1.2 supports AIFF, AU, WAV, MIDI (types 1 and 2
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
flex didn't know how to drag and drop video and audio in flip book - Framework
flex didn't know how to drag and drop video and audio in flip book  ... target to add the video audio and photo in this book i am able to add the photo in this book but i didn't able to add video and audio so pls help me for my project
ffmpeg audio from video
ffmpeg audio from video  Hi, How to extract audio from a video file? Thanks
converter code for audio file
converter code for audio file  how can i convert a audio file to a another file format like mp3
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
iPhone play, pause and stop playing music
iPhone play, pause and stop playing music This is the small iPhone SDK example that will show you how to play, pause and stop the music on button... that just drag and paste the music or audio file into the resources folder, which
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
audio video conferencing
audio video conferencing  how to develop a chat application in peer to peer setup
Broadcasting audio.. - JSP-Servlet
Broadcasting audio..  i am doing a project on Internet radio. I embeded windows media player,but doesnt know how to broadcast...i need to stream the audio. can anyone give a solution for this. Its very urgent
uploading audio file iphone
uploading audio file iphone  uploading audio file iphone
Audio MIDlet Example
Audio MIDlet Example       This example illustrates how to play audio songs in your... a player for an audio song by using of javax.microedition.media API. As you
stop word removal from text file
stop word removal from text file  i need java source code for stop word removal from a text file
audio file to play automatically
audio file to play automatically  I want to get an audio file to play automatically when someone visits my site
HTML audio tag
HTML audio tag  Hi, I have written a simple html page to play audio file, I m using audio tag as shown below: Your browser does not support the audio tag. when I open the page using Chrome, it works fine(plays audio
Audio files,IDE - Design concepts & design patterns
Audio files,IDE  HI! Gurus.I am david.i am a new to Java.i need detailed explanation on how to Create Audio files using Java language.Also i need... how to create games using Java?Please send answers to to this Questions to my E
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5.
HTML5 audio loop, Use of loop attribute of audio tag in  HTML5. Introduction:Loop attribute is used for reputation of audio or music. It repeats audio file again, until you do not click any controls. It supports only Boolean
audio files in jdbc connectivity with ms-access - JDBC
audio files in jdbc connectivity with ms-access  i need to know how to retrieve audio files through jdbc connectivity with ms-access and how to play...://www.roseindia.net/java/example/java/applet/PlaySoundApplet.shtml Hope
HTML5 audio autoplay, Use of autoplay attribute in audio tag.
HTML5 audio autoplay, Use of autoplay attribute in audio tag. Introduction:The autoplay is an audio tag attribute. It is only supported by HTML5. When it is present in audio tag, the music file will begin itself. or After loading
HTML5  audio tag example, Use of audio tag  in HTML5.
HTML5  audio tag example, Use of audio tag  in HTML5. Introduction:In this section, you will see the use and implementation of audio tag in HTML5. The <audio> tag is used to add audio in web page or HTML page. When
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag.
HTML5 audio autobuffer, Use of autobuffer attribute in audio tag. Introduction:The autobuffer attribute has Boolean value. It is available in audio tag... in audio tag file; music will start buffering automatically . Declaration
HTML5 audio controls, Discuss the controls attribute of audio tag.
HTML5 audio controls, Discuss the controls attribute of audio tag. Introduction:The controls is attribute of audio. which is used for showing media player on browser. It supports only Boolean value. If it is present in audio tag
J2ME Audio Record
J2ME Audio Record       This example is used to record the audio sound  and play the recorded sound. In this example we are trying to capture the audio sound and encoded
Code to STOP Students from navigating anywhere else till the Online exam is over
Code to STOP Students from navigating anywhere else till the Online exam is over  hi guys i am a final year student of engineering and i am working... or how to do so for BOTH VERSIONS i am using netbeans IDE but i will prefer
Car Music Streaming via iPhone Bluetooth, iphone Bluetooth Audio Streaming
Stream iPhone Music in Car Using Bluetooth One of the nicest features Apple added in its iPhone 3.0 release is the ability to stream music from the iPhone to the Car audio using Bluetooth. If your car has a supported Bluetooth
how to run java application with out stoping
how to run java application with out stoping  I have one java application to download some pdf file but its going to stop downloading after some time it not giving any errors any thing can any one help me to solve this problem
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp
data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp   data (image ,audio) inserting to data base (oracle 10g) and retriving the same data from jsp with script of data base plz help me
java - Java Beginners
java  How to send audio file through one mobile to another mobile using JAVA
how to destroy java thread
how to destroy java thread  how to destroy java thread?   This will help .. Shutting Down the Java Thread
how to add to numbers in java
how to add to numbers in java  how to add to numbers in java
how to create notepad in java
how to create notepad in java  how to create notepad in java
how to conduct the test in java
how to conduct the test in java  how to conduct the test in java
how and waht java
how and waht java  category the java req
Advertisements
 

 

 

DMCA.com