The objects are passed to the AudioPlayer methods to start and stop the stream. AudioPlayer instantiated to force run of static initializers. Unlike the other examples, the streams are not automatically rewound. If you choose a longer sound file, you will notice that the sound is resumed from the point in the stream at which you pressed Stop. The above examples show hard-coded values for the sound data, which is not something you would want to deal with in real life.
Many programs actually provide applet parameters or command-line arguments for sounds.
Another approach is to package sound files in a JAR file and refer to the sounds using published names. This next example takes 10 sounds from a JAR file, named 0.au , 1.au , and so on, and plays them in order. I borrowed my 10 sounds from the Sun JDK 1.1 animator program in the audio directory, but you can just as easily bundle 10 sounds of your own choosing. Although the sound-playing code is the same in this example as it is in the last example, the interesting code in this example involves the AppletClassLoader and AppletResourceLoader classes. These are in the sun.applet package, so like the sun.audio classes they suffer similar restrictions.