@Override public void changed (ChangeEvent event, Actor actor) { if (!sliderUpdating && slider.isDragging()) music.setPosition((slider.getValue() / 100f) * songDuration); } });
private void playMusicOnDemand() { if (!world.started) { world.started = true; if (hasMusic) { theSong.setLooping(false); theSong.setOnCompletionListener(this); theSong.setVolume(GlobalConfiguration.songVolume / 100f); } } else { if (world.paused) { world.paused = false; if (hasMusic) { theSong.setPosition(lastmtime); time = lastmtime + world.delay; theSong.play(); } } } }
@Override public void render(float delta) { Gdx.gl.glClearColor(0, 0, 0, 1); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); stage.act(); stage.draw(); if (theSong != null && theSong.isPlaying() && theSong.getPosition() > newBPosition) { theSong.setPosition(newAPosition); } }
theSong.setPosition(newAPosition); theSong.setVolume(GlobalConfiguration.songVolume / 100f); theSong.play();
@Override public void retrieveAssets() { if (voice == null && fileName != null) { 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 * VOLUME_MULTIPLIER); if (isPlayingSer) { voice.play(); if (voice != null) { voice.setPosition(voicePosSer); } isPlayingSer = false; voicePosSer = 0f; } } }
@Override public void retrieveAssets() { if (music == null && desc != null) { // Check if not loaded, this happens when setting a cached scene if (!EngineAssetManager.getInstance().isLoaded(EngineAssetManager.MUSIC_DIR + desc.getFilename())) { // Load the music file in background to avoid // blocking the UI loadTask(); return; } EngineLogger.debug("RETRIEVING MUSIC: " + desc.getFilename()); music = EngineAssetManager.getInstance().getMusic(desc.getFilename()); if (isPlayingSer) { playMusic(); if (music != null) { music.setPosition(musicPosSer); musicPosSer = 0f; } isPlayingSer = false; } } }
theSong.play(); if (aPosition != null) theSong.setPosition(aPosition); lastmtime = theSong.getPosition(); time = lastmtime + world.delay;
if (hasMusic) { theSong.pause(); theSong.setPosition(aPosition); theSong.play(); lastmtime = theSong.getPosition();