Search in sources :

Example 11 with Music

use of com.badlogic.gdx.audio.Music in project Catacomb-Snatch by Catacomb-Snatch.

the class GdxSoundPlayer method startTitleMusic.

@Override
public void startTitleMusic() {
    stopBackgroundMusic();
    stopEndMusic();
    Music titleMusic = getMusic(Sounds.TITLE_THEME);
    if (titleMusic == null) {
        return;
    }
    if (musicVolume > 0.0f && !titleMusic.isPlaying() && !paused) {
        titleMusic.setLooping(true);
        titleMusic.setVolume(musicVolume);
        titleMusic.play();
    }
    TitleIsPlaying = true;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Example 12 with Music

use of com.badlogic.gdx.audio.Music in project Catacomb-Snatch by Catacomb-Snatch.

the class GdxSoundPlayer method startBackgroundMusic.

@Override
public void startBackgroundMusic() {
    stopTitleMusic();
    stopEndMusic();
    if (musicVolume > 0.0f && backgroundMusicList.size > 0 && !paused) {
        if (backgroundPlaying < 0)
            backgroundPlaying = 0;
        Music music = backgroundMusicList.get(backgroundPlaying);
        if (music == null)
            return;
        if (!music.isPlaying()) {
            if (songEnded == 0) {
                songEnded = System.currentTimeMillis();
                backgroundPlaying = (backgroundPlaying + 1) >= backgroundMusicList.size ? 0 : backgroundPlaying + 1;
                music = backgroundMusicList.get(backgroundPlaying);
            }
            if (songEnded == 0 || (songEnded + (timeBetweenSongs * 1000)) < System.currentTimeMillis()) {
                music.setLooping(false);
                music.setVolume(musicVolume);
                music.play();
                songEnded = 0;
            }
        }
    }
    backgroundIsPlaying = true;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Example 13 with Music

use of com.badlogic.gdx.audio.Music in project bladecoder-adventure-engine by bladecoder.

the class VoiceManager method retrieveAssets.

@Override
public void retrieveAssets() {
    if (voice == null && fileName != null) {
        if (!EngineAssetManager.getInstance().isLoaded(EngineAssetManager.VOICE_DIR + fileName)) {
            loadAssets();
            try {
                EngineAssetManager.getInstance().finishLoading();
            } catch (GdxRuntimeException e) {
                EngineLogger.error(e.getMessage());
                voice = null;
                fileName = null;
                textManager.next();
                return;
            }
        }
        EngineLogger.debug("RETRIEVING VOICE: " + fileName);
        voice = EngineAssetManager.getInstance().get(EngineAssetManager.VOICE_DIR + fileName, Music.class);
        voice.setOnCompletionListener(new OnCompletionListener() {

            @Override
            public void onCompletion(Music music) {
                if (textManager.getCurrentText() != null)
                    textManager.getCurrentText().setAutoTime();
            }
        });
        if (voice != null)
            voice.setVolume(volume);
        if (isPlayingSer) {
            voice.play();
            if (voice != null) {
                voice.setPosition(voicePosSer);
            }
            isPlayingSer = false;
            voicePosSer = 0f;
        }
    }
}
Also used : GdxRuntimeException(com.badlogic.gdx.utils.GdxRuntimeException) OnCompletionListener(com.badlogic.gdx.audio.Music.OnCompletionListener) Music(com.badlogic.gdx.audio.Music)

Example 14 with Music

use of com.badlogic.gdx.audio.Music in project ultimate-java by pantinor.

the class Sounds method play.

public static Music play(Sound sound, float volume) {
    Music m = sounds.get(sound);
    if (m == null) {
        m = Gdx.audio.newMusic(Gdx.files.internal("assets/sound/" + sound.getFile()));
        sounds.put(sound, m);
    }
    m.setLooping(sound.getLooping());
    m.setVolume(volume);
    m.play();
    return m;
}
Also used : Music(com.badlogic.gdx.audio.Music)

Aggregations

Music (com.badlogic.gdx.audio.Music)14 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)2 OnCompletionListener (com.badlogic.gdx.audio.Music.OnCompletionListener)1 Sound (com.badlogic.gdx.audio.Sound)1 FileHandle (com.badlogic.gdx.files.FileHandle)1