congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
Music.dispose
Code IndexAdd Tabnine to your IDE (free)

How to use
dispose
method
in
com.badlogic.gdx.audio.Music

Best Java code snippets using com.badlogic.gdx.audio.Music.dispose (Showing top 20 results out of 315)

origin: libgdx/libgdx

  @Override
  public void dispose () {
    batch.dispose();
    buttons.getTexture().dispose();
    music.dispose();
  }
}
origin: libgdx/libgdx

void setSong (Song song) {
  if (music != null) {
    music.dispose();
  }
  switch (song) {
  default:
  case MP3:
    music = Gdx.audio.newMusic(Gdx.files.internal("data/8.12.mp3"));
    songDuration = 183;
    break;
  case OGG:
    music = Gdx.audio.newMusic(Gdx.files.internal("data/cloudconnected.ogg"));
    songDuration = 22;
    break;
  case WAV:
    music = Gdx.audio.newMusic(Gdx.files.internal("data/8.12.loop.wav"));
    songDuration = 4;
    break;
  }
  music.setLooping(btLoop.isChecked());
  music.play();
}
origin: dsaltares/libgdx-cookbook

@Override
public void dispose() {
  for (Music song : songs) {
    song.dispose();
  }
}

origin: com.harium.etyl/etyl-gdx

public void dispose() {
  music.dispose();
}
origin: 00-Evan/shattered-pixel-dungeon-gdx

public void stop() {
  if (player != null) {
    player.stop();
    player.dispose();
    player = null;
  }
}

origin: BrentAureli/FlappyDemo

@Override
public void dispose() {
  super.dispose();
  music.dispose();
}
origin: bladecoder/bladecoder-adventure-engine

@Override
public void dispose() {
  for (Texture t : images.values())
    t.dispose();
  images.clear();
  credits.clear();
  if (music != null) {
    music.stop();
    music.dispose();
    music = null;
  }
}
origin: dingjibang/GDX-RPG

/**卸载所有音乐,清除循环*/
public void disposeAll() {
  Stream.of(manager.values()).forEach(p -> p.music.dispose());
  manager.clear();
  
  //取消循环托管
  Timer.remove(loopTask);
}
 
origin: langurmonkey/gaiasky

private void disposeInstance() {
  if (currentMusic != null) {
    currentMusic.stop();
    currentMusic.dispose();
  }
  if (EventManager.instance != null)
    EventManager.instance.unsubscribe(this, Events.MUSIC_NEXT_CMD, Events.MUSIC_PLAYPAUSE_CMD, Events.MUSIC_PREVIOUS_CMD, Events.MUSIC_VOLUME_CMD, Events.MUSIC_RELOAD_CMD);
}
origin: lycying/c2d-engine

  public void dispose(){
    for(Music music:musics.values()){
      if(null!=music)music.dispose();
    }
    this.musics.clear();
    this.musicVolume = 1.0f;
  }
}
origin: kbz/SIFTrain

private void disposeOf(Music mus) {
  if(mus == null)
    return;;
  if(mus.isPlaying())
    mus.stop();
  mus.dispose();
}
origin: org.mini2Dx/mini2Dx-core

/**
 * Cleans up resources. To be called when this instance is no longer needed.
 */
public void dispose() {
  if (isPlaying()) {
    throw new RuntimeException("Cannot dispose of a music instance that is currently playing");
  }
  if(currentTrack.isPlaying()) {
    currentTrack.stop();
  }
  if(nextTrack.isPlaying()) {
    nextTrack.stop();
  }
  currentTrack.dispose();
  nextTrack.dispose();
  scheduledExecutorService.shutdown();
}
origin: bladecoder/bladecoder-adventure-engine

private void processCreditMusic(final String s) {
  if (music != null)
    music.dispose();
  
  final String sound = EngineAssetManager.getInstance().checkIOSSoundName("music/" + s);
  new Thread() {
    @Override
    public void run() {
      music = Gdx.audio.newMusic(EngineAssetManager.getInstance().getAsset(sound));
      
      try {
        music.play();
      } catch(Exception e) {
        // sometimes the play method fails on desktop.
        EngineLogger.error("Error Playing music: " + s, e);
      }
    }
  }.start();    
}
origin: dsaltares/libgdx-cookbook

@Override
public void dispose() {
  map.dispose();
  renderer.dispose();
  atlas.dispose();
  batch.dispose();
  song.dispose();
}
origin: danialgoodwin/dev

@Override
public void dispose() {
  dropImage.dispose();
  bucketImage.dispose();
  dropSound.dispose();
  rainMusic.dispose();
  batch.dispose();
}
origin: kbz/SIFTrain

  @Override
  public void clicked(InputEvent event, float x, float y) {
    if (theSong != null)
    {
      theSong.stop();
      theSong.dispose();
    }
    ((Game) Gdx.app.getApplicationListener()).setScreen(new SongSelectionScreen());
  }
}));
origin: kbz/SIFTrain

  @Override
  public void clicked(InputEvent event, float x, float y) {
    if (theSong != null)
    {
      theSong.stop();
      theSong.dispose();
    }
    ((Game) Gdx.app.getApplicationListener()).setScreen(new SongScreen());
  }
}));
origin: kbz/SIFTrain

@Override
public boolean keyUp(int keycode) {
  if (keycode == Input.Keys.BACK || keycode == Input.Keys.ESCAPE) {
    if (theSong != null)
    {
      theSong.stop();
      theSong.dispose();
    }
    ((Game) Gdx.app.getApplicationListener()).setScreen(new SongSelectionScreen());
    // do nothing
    return true;
  }
  return false;
}
origin: bladecoder/bladecoder-adventure-engine

@Override
public void dispose() {
  if (stage != null) {
    stage.dispose();
    stage = null;
    if (bgTexFile != null) {
      bgTexFile.dispose();
      bgTexFile = null;
    }
    if (titleTexFile != null) {
      titleTexFile.dispose();
      titleTexFile = null;
    }
    if (music != null) {
      music.stop();
      music.dispose();
      music = null;
    }
  }
}
origin: langurmonkey/gaiasky

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);
  }
}
com.badlogic.gdx.audioMusicdispose

Javadoc

Needs to be called when the Music is no longer needed.

Popular methods of Music

  • play
    Starts the play back of the music stream. In case the stream was paused this will resume the play ba
  • stop
    Stops a playing or paused Music instance. Next time play() is invoked the Music will start from the
  • isPlaying
  • setLooping
    Sets whether the music stream is looping. This can be called at any time, whether the stream is play
  • setVolume
    Sets the volume of this music stream. The volume must be given in the range [0,1] with 0 being silen
  • pause
    Pauses the play back. If the music stream has not been started yet or has finished playing a call to
  • getPosition
    Returns the playback position in seconds.
  • setPosition
    Set the playback position in seconds.
  • setOnCompletionListener
    Register a callback to be invoked when the end of a music stream has been reached during playback.
  • getVolume

Popular in Java

  • Start an intent from android
  • getExternalFilesDir (Context)
  • compareTo (BigDecimal)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • ObjectMapper (com.fasterxml.jackson.databind)
    ObjectMapper provides functionality for reading and writing JSON, either to and from basic POJOs (Pl
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • Base64 (org.apache.commons.codec.binary)
    Provides Base64 encoding and decoding as defined by RFC 2045.This class implements section 6.8. Base
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now