Results 1 to 1 of 1
- 11-02-2012, 09:08 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 14
- Rep Power
- 0
Music files not stopping even after closing browser
Hi, in my JApplet, I play music files when you click on a button. When I close the applet window in eclipse, the sound stops playing.
However, when I run my applet in a browser, the sound continues and keeps on going until the song finishes. I even included destroy() and stop() functions in which I end the music
Java Code:public class birthday extends JApplet { .... JPanel songBoard; JButton song1; JButton song2; JButton song3; JButton song4; AudioClip song; URL songPath; boolean isPlaying = false; ... public void init() { songBoard = new JPanel(); songBoard.setLayout(new FlowLayout()); songBoard.setBounds(180, 50, 700, 500); songBoard.setOpaque(true); song1 = new JButton("In the End"); song2 = new JButton("What I've Done"); song3 = new JButton("New Divide"); song4 = new JButton("Somewhere I Belong"); song1.addActionListener(action); song2.addActionListener(action); song3.addActionListener(action); song4.addActionListener(action); songBoard.add(song1); songBoard.add(song2); songBoard.add(song3); songBoard.add(song4); pane.add(songBoard, new Integer(1)); //a JLayeredPane ... } private class ActionListenerClass implements ActionListener { @Override 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 playSong() { song.play(); isPlaying = true; progress.setValue(50); songBoard.setVisible(false); } public void destroy() { if(isPlaying) song.stop(); } public void stop() { if(isPlaying == true) song.stop(); }
Similar Threads
-
how to copy the files from fileserver to local path via browser?
By mariaprabudass in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 12-12-2011, 04:00 PM -
Displaying The Content of Doc files in Web Browser
By mitesh1984_agrawal in forum Java ServletReplies: 0Last Post: 04-15-2010, 08:41 AM -
Open and closing tabbed web browser using java
By rijeshmenon in forum Advanced JavaReplies: 0Last Post: 12-14-2009, 09:44 AM -
How to detect browser closing to invalidate a jsp session
By kumar_ps78 in forum JavaServer Pages (JSP) and JSTLReplies: 13Last Post: 08-13-2009, 03:56 PM -
restrict users from entering the image/text files path directly in the browser.
By vishnujava in forum Java ServletReplies: 6Last Post: 08-06-2008, 01:41 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks