Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Sound in browser not ending properly

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Sound in browser not ending properly

    Hi, I have a song that is played when a user click on a button. When they close the window, the song should end, but it doesn't. I even have the songs stop playing in the stop() and destroy() functions, but it isn't working. It only works when it runs in eclipse's applet viewer.
    AudioClip song;
    .....
    	public void actionPerformed(ActionEvent evt) {
     
    			if(evt.getSource() == song1)
    			{
    				song= getAudioClip(getDocumentBase(), "In The End.wav");
    				playSong();
    			}
    			else if(evt.getSource() == song2)
    			{
    				song = getAudioClip(getDocumentBase(), "What I've Done.wav");
    				playSong();
    			}
    			else if(evt.getSource() == song3)
    			{
    				song = getAudioClip(getDocumentBase(), "New Divide.wav");
    				playSong();
    			}
    			else if(evt.getSource() == song4)
    			{
    				song = getAudioClip(getDocumentBase(), "Somewhere I Belong.wav");
    				playSong();
    			}
     
    		}
    public void destroy()
    	{
    		if(isPlaying)
    			song.stop();
    	}
    	public void stop()
    	{
    		if(isPlaying == true)
    			song.stop();
    	}


  2. #2
    Junior Member
    Join Date
    Nov 2012
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Sound in browser not ending properly

    Also, the sound files aren't being properly played. I keep on hearing cracks and stops in between. Does anyone know why?

Similar Threads

  1. Program not ending correctly
    By alex067 in forum What's Wrong With My Code?
    Replies: 9
    Last Post: October 15th, 2012, 07:54 AM
  2. Having trouble ending a game
    By wakaxwaka in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 24th, 2012, 06:33 PM
  3. [SOLVED] JOptionPane preventing program from ending
    By RichTea in forum AWT / Java Swing
    Replies: 2
    Last Post: February 23rd, 2012, 06:42 AM
  4. Replies: 0
    Last Post: January 12th, 2012, 02:54 PM
  5. program loops never ending
    By Ccogh05 in forum Loops & Control Statements
    Replies: 5
    Last Post: February 24th, 2011, 12:42 AM

Tags for this Thread