Wednesday, July 04, 2007

How to play a sound file in an Applet

This Java tip illustrates a method of playing audio files in Java applets. Developer needs to to take care that the audio clip resides on the same web server where your applet resides. Some time it may be the case that the developer may need to sign the applet to get the audio file from the server.
public void init() {

// The first thing is to load the audio clip
AudioClip clip = getAudioClip(getDocumentBase(),

// Play the audio clip;

// Stop playing audio clip

// In case audio clip needs to be played continuously

No comments: