Java Code Examples for com.badlogic.gdx.audio.Music#setLooping()

The following examples show how to use com.badlogic.gdx.audio.Music#setLooping() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AudioManager.java    From Norii with Apache License 2.0 6 votes vote down vote up
private Music playMusic(boolean isLooping, String fullFilePath){
    Music music = queuedMusic.get(fullFilePath);
    if( music != null ){
        music.setLooping(isLooping);
        music.play();
    }else if(Utility.isAssetLoaded(fullFilePath)){
        music = Utility.getMusicAsset(fullFilePath);
        music.setLooping(isLooping);
        music.play();
        queuedMusic.put(fullFilePath, music);
    }else{
        Gdx.app.debug(TAG, "Music not loaded");
        return null;
    }
    return music;
}
 
Example 2
Source File: SoundManager.java    From dice-heroes with GNU General Public License v3.0 6 votes vote down vote up
public void playMusicBeautifully(String name, Stage stage) {
    final Music music = musics.get(name);
    if (music == null) {
        Logger.error("there is no music for " + name);
        return;
    }
    music.setVolume(0);
    if (!usesMusic) {
        disabledMusics.add(music);
    } else {
        music.play();
    }
    music.setLooping(true);
    playingMusics.add(music);
    Action action = new TemporalAction(5f, Interpolation.linear) {
        @Override protected void update(float percent) {
            music.setVolume(percent * volume);
        }
    };
    stage.addAction(action);
    replaceAction(music, action);
}
 
Example 3
Source File: GameManager.java    From Bomberman_libGdx with MIT License 6 votes vote down vote up
public void playMusic(String musicName, boolean isLooping) {
    Music music = assetManager.get(musicPath + musicName);
    music.setVolume(0.6f);
    if (currentMusic.equals(musicName)) {
        music.setLooping(isLooping);
        if (!music.isPlaying()) {
            music.play();
        }
        return;
    }

    stopMusic();
    music.setLooping(isLooping);
    music.play();
    currentMusic = musicName;
}
 
Example 4
Source File: Crossfader.java    From SIFTrain with MIT License 4 votes vote down vote up
private void initMusic(Music mus) {
    mus.setLooping(true);
    mus.setVolume(0.0f);
    mus.play();
}