Package com.drakulo.games.ais.core.audio

Source Code of com.drakulo.games.ais.core.audio.MusicManager

package com.drakulo.games.ais.core.audio;

import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;

public final class MusicManager {
  private static final String BASE = "data/audio/music/";
  private static final String EXT = ".ogg";
  private static final MusicManager INSTANCE = new MusicManager();

  public static final String M1 = BASE + "M1";

  private String playingMusic;

  private MusicManager() {
    playingMusic = null;
  }

  public static MusicManager getInstance() {
    return INSTANCE;
  }

  public void playMusic(String key) {
    Music m;
    try {
      m = new Music(key + EXT, true);
      // m.setVolume(0.1F);
      m.loop();
      playingMusic = key;
    } catch (SlickException e) {
      System.out.println("Could not play sound : " + key + EXT);
      e.printStackTrace();
    }
  }

  public String getPlayingMusic() {
    return playingMusic;
  }
}
TOP

Related Classes of com.drakulo.games.ais.core.audio.MusicManager

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.