List of usage examples for com.badlogic.gdx.audio Music dispose
public void dispose();
From source file:at.therefactory.jewelthief.JewelThief.java
License:Open Source License
/** * Either continues the music playback of a previously paused music file or proceeds to the next music file depending on the proceedToNext flag. * If there was no previous music file, a new music file is chosen randomly. * @param proceedToNext If set to true, a new music file is chosen randomly. If set to false, the previously paused file is being resumed. *///from w w w. j a v a 2s . c om public void playMusicFile(boolean proceedToNext) { // remember all available music files if (musicFiles == null) { FileHandle dirHandle = Gdx.files.internal("audio/music"); FileHandle[] fileList = dirHandle.list(); musicFiles = new String[fileList.length]; for (int i = 0; i < musicFiles.length; i++) { musicFiles[i] = fileList[i].path(); Gdx.app.log(getClass().getName(), "Found '" + fileList[i].path() + "'"); } } if (musicFiles.length == 0) { Gdx.app.error(getClass().getName(), "Could not find any music files!"); } else { // select a music file to play if (currentMusicFile == -1) { // if there is no previous music file, choose a new one randomly currentMusicFile = (short) Utils.randomWithin(0, musicFiles.length - 1); music = loadMusicAsset(musicFiles[currentMusicFile]); } else if (proceedToNext) { // switch to the next music file randomly int previousMusicFile = currentMusicFile; do { currentMusicFile = (short) Utils.randomWithin(0, musicFiles.length - 1); } while (previousMusicFile == currentMusicFile); assetManager.unload(musicFiles[previousMusicFile]); // free the resources of the previous music file if (music != null) { music.dispose(); music = null; } music = loadMusicAsset(musicFiles[currentMusicFile]); } else { // resume previously paused music file } // play the selected music file music.play(); music.setOnCompletionListener(new Music.OnCompletionListener() { @Override public void onCompletion(Music music) { playMusicFile(true); } }); } }
From source file:com.github.badoualy.badoualyve.ui.stage.IntroStage.java
License:Open Source License
@Override public boolean keyDown(int keyCode) { if (keyCode == Input.Keys.ENTER && dialog.getInputValue().length() > 0) { startSound.setOnCompletionListener(new Music.OnCompletionListener() { @Override//from w w w . j a v a2s . c o m public void onCompletion(Music music) { music.dispose(); listener.onSignIn(dialog.getInputValue()); } }); startSound.play(); game().setScreen(new FixedFpsScreen(new LoadingStage(), 30)); } else if (keyCode == Input.Keys.BACKSPACE) { dialog.setInputValue(dialog.getInputValue().substring(0, dialog.getInputValue().length() - 1)); } return super.keyDown(keyCode); }
From source file:com.jupiter.europa.audio.LocalAudioService.java
License:Open Source License
@Override public void dispose() { this.musicSets.keySet().stream().forEach((key) -> { for (Music music : this.musicSets.get(key)) { music.dispose(); }/*from w w w. ja v a 2s . c o m*/ }); }
From source file:com.mygdx.game.AudioPlayer.java
public void dispose() { for (Sound s : sfx.values()) s.dispose();/*from ww w . j av a 2 s .com*/ for (Music m : music.values()) m.dispose(); }
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);//from www. jav a 2s .co m 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:com.torrosoft.triviazo.services.music.MusicManager.java
License:Open Source License
/** * Stops and disposes the current music being played, if any. *//*from ww w.ja v a 2 s .c o m*/ public final void stop() { if (musicBeingPlayed != null) { final Music musicResource = musicBeingPlayed.getMusicResource(); musicResource.stop(); musicResource.dispose(); musicBeingPlayed = null; } }
From source file:fr.plafogaj.screens.MainMenu.java
License:Open Source License
@Override public void dispose() { for (Disposable t : m_texturesList) t.dispose();/*from w ww . ja v a 2s.c o m*/ for (Disposable d : m_soundList) d.dispose(); for (Music m : m_ambianceMusicList) m.dispose(); m_stage.dispose(); }
From source file:game.Content.java
public static void removeMusic(String key) { Music m = music.get(key); if (m != null) { music.remove(key);/*w w w . j av a 2 s . c om*/ m.dispose(); } }
From source file:game.Content.java
/*********/ public static void removeAll() { /*Iterator<Map.Entry<String, Texture>> iter1 = textures.entrySet().iterator(); while(iter1.hasNext()) {// www. j a v a 2 s . co m Texture tex = iter1.next().getValue(); tex.dispose(); iter1.remove(); } Iterator<Map.Entry<String, Music>> iter2 = music.entrySet().iterator(); while(iter2.hasNext()) { Music music = iter2.next().getValue(); music.dispose(); iter2.remove(); } Iterator<Map.Entry<String, Sound>> iter3 = sounds.entrySet().iterator(); while(iter3.hasNext()) { Sound sound = iter3.next().getValue(); sound.dispose(); iter3.remove(); }*/ for (Object o : textures.values()) { Texture tex = (Texture) o; tex.dispose(); } textures.clear(); for (Object o : music.values()) { Music music = (Music) o; music.dispose(); } music.clear(); for (Object o : sounds.values()) { Sound sound = (Sound) o; sound.dispose(); } sounds.clear(); }
From source file:net.k3rnel.unsealed.services.MusicManager.java
License:Open Source License
/** * Stops and disposes the current music being played, if any. *///from w ww .j a v a 2 s.com public void stop() { if (musicBeingPlayed != null) { Gdx.app.log(Unsealed.LOG, "Stopping current music"); Music musicResource = musicBeingPlayed.getMusicResource(); musicResource.stop(); musicResource.dispose(); musicBeingPlayed = null; } }