Ejemplo n.º 1
0
  private void play(String resource) {
    removeSound();

    sound =
        AudioFactory.getInstance().makeAudioSource("ExtractorAudio", resource, Vector3f.ZERO, true);
    sound.setLooping(true);
    sound.setShowRange(true);

    ((Node) getSpatial()).attachChild(sound);
    // audioRenderer.playSource(music);
    sound.setPositional(true);
    sound.setVolume(0.7f);
    sound.setReverbEnabled(false);
    sound.setDirectional(false);
    sound.setMaxDistance(Float.MAX_VALUE);
    sound.setRefDistance(1f);
    // music.setRolloffFactor(1f);
    // music.setLooping(false);

    sound.setShowRange(enabledRange);
    sound.play();
  }
Ejemplo n.º 2
0
 private void removeSound() {
   if (sound != null) {
     sound.stop();
     sound.removeFromParent();
   }
 }