List of usage examples for com.badlogic.gdx.audio Music isPlaying
public boolean isPlaying();
From source file:com.forerunnergames.peril.client.ui.music.MusicController.java
License:Open Source License
private void stopMusicWithFadeOut(final Music music) { Timer.schedule(new Timer.Task() { @Override//from ww w .ja va 2 s . co m public void run() { if (!music.isPlaying()) { cancel(); log.trace("Stopping fading out music [{}] because it isn't playing anymore.", music); return; } final float currentVolume = music.getVolume(); final float delta = masterVolume.getVolume() / MusicSettings.FADE_VOLUME_REPEAT_COUNT; final float newVolume = currentVolume - delta; log.trace("Fading out music [{}] from volume [{}] to volume [{}].", music, currentVolume, newVolume); if (newVolume <= MusicSettings.MIN_VOLUME) { music.stop(); cancel(); log.trace("Done fading out & stopping music [{}].", music); return; } music.setVolume(newVolume); } }, 0.0f, MusicSettings.FADE_VOLUME_INTERVAL_SECONDS, MusicSettings.FADE_VOLUME_REPEAT_COUNT); }
From source file:com.forerunnergames.peril.client.ui.music.MusicController.java
License:Open Source License
private void startMusicWithFadeIn(final Music music) { music.setVolume(MusicSettings.MIN_VOLUME); music.play();/*w w w .j a va 2 s . com*/ Timer.schedule(new Timer.Task() { @Override public void run() { if (!music.isPlaying()) { cancel(); log.trace("Stopping fading in music [{}] because it isn't playing anymore.", music); return; } final float currentVolume = music.getVolume(); final float delta = masterVolume.getVolume() / MusicSettings.FADE_VOLUME_REPEAT_COUNT; final float newVolume = currentVolume + delta; log.trace("Fading in music [{}] from volume [{}] to volume [{}].", music, currentVolume, newVolume); if (newVolume > masterVolume.getVolume()) { cancel(); log.trace("Done fading in music [{}].", music); return; } music.setVolume(newVolume); } }, 0.0f, MusicSettings.FADE_VOLUME_INTERVAL_SECONDS, MusicSettings.FADE_VOLUME_REPEAT_COUNT); }
From source file:com.mangecailloux.pebble.audio.MusicManager.java
License:Apache License
/** Remove a {@link Music}. This will not unload the music. * @param _key ID of the music instance. *///from w w w. j ava 2s. c om public void unregister(String _key) { Music music = musics.get(_key); if (music != null && music.isPlaying()) music.stop(); musics.remove(_key); }
From source file:com.mangecailloux.pebble.audio.MusicManager.java
License:Apache License
/** * Play the music.// w w w.j a va2 s . co m * @param _key ID of the music. * @param _looping if true, music will loop. */ public void play(String _key, boolean _looping) { Music music = get(_key); if (music != null && !music.isPlaying()) { music.play(); music.setLooping(_looping); } }
From source file:com.mangecailloux.pebble.audio.MusicManager.java
License:Apache License
/** * Stop the Music.//from w w w.j a v a2 s . com * @param _key ID of the music. */ public void stop(String _key) { Music music = get(_key); if (music != null && music.isPlaying()) { music.stop(); } }
From source file:com.mangecailloux.pebble.audio.MusicManager.java
License:Apache License
/** * @param _key ID of the music./*w ww . java 2 s.c om*/ * @return true is the music is playing. */ public boolean isPlaying(String _key) { Music music = get(_key); if (music != null) { return music.isPlaying(); } return false; }
From source file:com.maplescot.loggerbill.misc.Assets.java
License:Creative Commons License
/** * Play that funky music, white boy.//from w ww . j a v a 2 s.c o m * * @param play True to play, else stop. */ public void playMusic(boolean play) { if (!initialized || !assetManager.isLoaded(Constants.MUSIC)) return; // Don't do anything if initialization isn't complete Music music = assetManager.get(MUSIC, Music.class); if (play && !music.isPlaying()) { music.setLooping(true); music.setVolume(0.85f); music.play(); Gdx.app.log(TAG, "Music is playing"); } else if (music.isPlaying() && !play) { Gdx.app.log(TAG, "Stopping music"); music.pause(); } }
From source file:com.paulogaspar.ninja.screens.Credits.java
public Credits(MyGame game, Ninja player, Texture master_texture[], Texture item_texture[], Texture cannonD, Texture cannonR, Texture cannonL, Texture cannonBall, Texture ninja_star, BitmapFont font_32, BitmapFont font_16, Music m, Sound bomb_sound, Sound item_sound) { batch = new SpriteBatch(); camera = new OrthographicCamera(); camera.setToOrtho(false, 800, 600);// w ww . j av a 2 s . com this.player = player; this.game = game; this.ninja_star = ninja_star; this.cannonD = cannonD; this.cannonL = cannonL; this.cannonR = cannonR; this.cannonBall = cannonBall; this.master_texture = master_texture; this.item_texture = item_texture; this.font_32 = font_32; this.font_16 = font_16; this.bomb_sound = bomb_sound; this.item_sound = item_sound; while (m.isPlaying()) { m.stop(); } m.dispose(); try { main_theme = Gdx.audio.newMusic(Gdx.files.internal("Music/end.mp3")); } catch (Exception e) { } while (!main_theme.isPlaying()) { try { main_theme.play(); main_theme.setVolume(player.master_volume); main_theme.setLooping(true); } catch (Exception e) { main_theme.stop(); } } init(); }
From source file:me.scarlet.undertailor.audio.MusicFactory.java
License:Open Source License
@Override public boolean isDisposable(com.badlogic.gdx.audio.Music music) { return !music.isPlaying(); }