The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.sound.sampled  [9 examples] > Playing  [3 examples]

e725. Continuously Playing a Sampled Audio File

Only DataLine objects that are of type Clip can be repeated. To create a clip, see e723 Loading and Playing Sampled Audio.
    // Play once
    clip.start();
    
    // Play and loop forever
    clip.loop(Clip.LOOP_CONTINUOUSLY);
    
    // Play and repeat for a certain number of times
    int numberOfPlays = 3;
    clip.loop(numberOfPlays-1);

 Related Examples
e723. Loading and Playing Sampled Audio
e724. Playing Streaming Sampled Audio

See also: Events    Properties   


© 2002 Addison-Wesley.