All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.lessvoid.nifty.gdx.sound.GdxSoundDevice Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package de.lessvoid.nifty.gdx.sound;

import com.badlogic.gdx.assets.AssetManager;

import de.lessvoid.nifty.sound.SoundSystem;
import de.lessvoid.nifty.spi.sound.SoundDevice;
import de.lessvoid.nifty.spi.sound.SoundHandle;
import de.lessvoid.nifty.tools.resourceloader.NiftyResourceLoader;

import javax.annotation.Nonnull;

/**
 * This is the sound device that uses libGDX to play the sounds.
 *
 * @author Martin Karing <[email protected]>
 */
public class GdxSoundDevice implements SoundDevice {
  /**
   * The asset manager used to load the sound and music files.
   */
  private final AssetManager assetManager;

  /**
   * Create a new sound device that uses libGDX.
   *
   * @param assetManager the asset manager
   */
  public GdxSoundDevice(final AssetManager assetManager) {
    this.assetManager = assetManager;
  }

  @Override
  public void setResourceLoader(@Nonnull final NiftyResourceLoader niftyResourceLoader) {
    // nothing to do
  }

  @Nonnull
  @Override
  public SoundHandle loadSound(@Nonnull final SoundSystem soundSystem, @Nonnull final String filename) {
    return new GdxSoundHandle(assetManager, soundSystem, filename);
  }

  @Override
  public SoundHandle loadMusic(@Nonnull final SoundSystem soundSystem, @Nonnull final String filename) {
    return new GdxMusicHandle(assetManager, soundSystem, filename);
  }

  @Override
  public void update(final int delta) {
    // nothing to do
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy