The two versions of this method return an instance of an AudioClip object. The AudioClip interface supports the play , loop , and stop methods so that a user can stop a sound once started. The code below shows how to create an AudioClip object from a URL and how to use the play , loop , and stop methods of the AudioClip class. Playing a sound with an AudioClip object This method is more useful for longer sounds and gives the user the ability to stop or loop the sound. If you want to pause, resume, and reset a sound, you must employ the AudioStream , AudioDataStream , and ContinuousAudioDataStream classes.
Some browsers require security to be loosened to run a class in the sun.audio package.
Usually the security can be set from a dialog box or command-line option. Given the above restrictions, the sun.audio package gives you the most flexibility in starting, stopping, and resetting a sound. The code below demonstrates how to implement a resettable sound stream. The first part of the init method shows you how to get a sound from an input file stream. This sound can just as easily come from a URL or any other type of input stream.