void playSong(int songIdx) { Music song = songs.get(currentSongIdx); song.setOnCompletionListener(null); song.stop(); currentSongIdx = songIdx; song = songs.get(currentSongIdx); song.play(); song.setVolume(volume); song.setOnCompletionListener(listener); }
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 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; } } }
if (hasMusic) { theSong.setLooping(false); theSong.setOnCompletionListener(this); theSong.setVolume(GlobalConfiguration.songVolume / 100f); theSong.play();
private void playIndex(int i) { FileHandle f = musicFiles.get(i); if (currentMusic != null) { if (currentMusic.isPlaying()) { currentMusic.stop(); } currentMusic.dispose(); } try { currentMusic = Gdx.audio.newMusic(f); currentMusic.setVolume(volume); currentMusic.setOnCompletionListener(new OnCompletionListener() { @Override public void onCompletion(Music music) { playNextMusic(); } }); currentMusic.play(); EventManager.instance.post(Events.MUSIC_TRACK_INFO, musicFiles.get(i).name()); logger.info(I18n.bundle.format("gui.music.playing", musicFiles.get(i).name())); } catch (Exception e) { logger.error(e); } }