Search in sources :

Example 1 with OnCompletionListener

use of com.badlogic.gdx.audio.Music.OnCompletionListener 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)

Aggregations

Music (com.badlogic.gdx.audio.Music)1 OnCompletionListener (com.badlogic.gdx.audio.Music.OnCompletionListener)1 GdxRuntimeException (com.badlogic.gdx.utils.GdxRuntimeException)1