|
-
September 7th, 2001, 02:17 AM
#9
Re: Playing Sound from Applet
Dear
Thank you very much for your suggestion. I had done that before. Actually I replace Applet word with this so it work well. Any way thank you very much for your replay. My code is as under:
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import java.net.URL;
/*
<applet code="MySound" width=200 height=200>
</applet>
*/
public class MySound extends Applet implements ActionListener {
Button bPlay;
AudioClip audioClip;
URL clipPath;
public void init() {
bPlay = new Button("Play Sound");
try {
clipPath = new URL(this.getCodeBase()+"gradually.wav");
}
catch(Exception e) { }
audioClip = this.newAudioClip(clipPath);
add(bPlay);
bPlay.addActionListener(this);
}
public void actionPerformed(ActionEvent ae) {
if(ae.getSource() == bPlay) {
audioClip.play();
}
}
}
Ajay Parmar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|