Playing an audio file multiple times (Clip)

Purpose.  Plays a single audio file multiple times in sequence. Demonstrates the usage of Java Sound's Clip.


java ClipPlayer audiofile #loops



the name of the audio file that should be played


how often the file should be repeated (0 means play once)

Bugs, limitations. Only PCM encoded files are supported. A-law, μ-law, ADPCM, ogg vorbis, mp3, GSM and other compressed data formats are not supported. For a technique of handling these see AudioPlayer.

Source code.