Example usage for javax.media.j3d BackgroundSound setLoop

List of usage examples for javax.media.j3d BackgroundSound setLoop

Introduction

In this page you can find the example usage for javax.media.j3d BackgroundSound setLoop.

Prototype

public void setLoop(int loopCount) 

Source Link

Document

Sets a sound's loop count.

Usage

From source file:SimpleSounds.java

/**
 * This adds a continuous background sound to the branch group.
 * /*from  w  ww  .j  av a2s .  co m*/
 * @param b
 *            BranchGroup to add the sound to.
 * @param soundFile
 *            String that is the name of the sound file.
 */
protected void addBackgroundSound(BranchGroup b, String soundFile) {
    //Create a media container to load the file
    MediaContainer droneContainer = new MediaContainer(soundFile);
    //Create the background sound from the media container
    BackgroundSound drone = new BackgroundSound(droneContainer, 1.0f);
    //Activate the sound
    drone.setSchedulingBounds(bounds);
    drone.setEnable(true);
    //Set the sound to loop forever
    drone.setLoop(BackgroundSound.INFINITE_LOOPS);
    //Add it to the group
    b.addChild(drone);
}