Tabnine Logo
Music.setVolume
Code IndexAdd Tabnine to your IDE (free)

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

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

origin: langurmonkey/gaiasky

/**
 * Sets the seeker of this music manager. The seeker must be given in the range [0,1] with 0 being silent and 1 being the maximum seeker.
 *
 * @param volume
 */
public void setVolume(float volume) {
  this.volume = volume;
  if (currentMusic != null) {
    currentMusic.setVolume(this.volume);
  }
}
origin: Mknsri/Drunk-Toss

  public static void muteMusic() {
    if (muteMusic) {
      menuMusic.setVolume(0f);
    } else {
      menuMusic.setVolume(1f);
    }
  }
}
origin: nifty-gui/nifty-gui

@Override
public void setVolume(final float volume) {
 currentVolume = volume;
 music.setVolume(volume);
}
origin: bladecoder/bladecoder-adventure-engine

public void setVolume(float volume) {
  this.volume = volume;
  if (voice != null)
    voice.setVolume(volume * VOLUME_MULTIPLIER);
}
origin: com.github.nifty-gui/nifty-libgdx-renderer

@Override
public void setVolume(final float volume) {
 currentVolume = volume;
 music.setVolume(volume);
}
origin: 00-Evan/shattered-pixel-dungeon-gdx

public void volume( float value ) {
  volume = value;
  if (player != null) {
    player.setVolume( value );
  }
}

origin: dingjibang/GDX-RPG

public MusicProxy(Music music) {
  this.music = music;
  music.setVolume(Game.setting.volume * Game.setting.musicVolume);
}
 
origin: lycying/c2d-engine

public void setVolume(float volume){
  for(Music music:musics.values()){
    music.setVolume(volume);
  }
  this.musicVolume = volume;
}
origin: org.mini2Dx/mini2Dx-core

private void fadeOutCurrentTrack() {
  float trackTargetVolume = MathUtils.clamp(1f - ((cursor - crossfadeTime) / crossfadeDuration), 0f,
      targetVolume);
  currentTrack.setVolume(trackTargetVolume);
}
origin: bladecoder/bladecoder-adventure-engine

public void setVolume(float volume) {
  if (desc != null)
    desc.setVolume(volume);
  if (music != null && music.isPlaying())
    music.setVolume(volume);
}
origin: kbz/SIFTrain

private void initMusic(Music mus) {
  mus.setLooping(true);
  mus.setVolume(0.0f);
  mus.play();
}
origin: dsaltares/libgdx-cookbook

void changeVolume(float volumeChange) {
  Music song = songs.get(currentSongIdx);
  volume = MathUtils.clamp(song.getVolume() + volumeChange, 0.0f, 1.0f);
  song.setVolume(volume);
}

origin: org.mini2Dx/mini2Dx-core

private void fadeInNextTrack() {
  float trackTargetVolume = MathUtils.clamp(((cursor - crossfadeTime) / crossfadeDuration), 0f,
      targetVolume);
  nextTrack.setVolume(trackTargetVolume);
  if (!nextTrack.isPlaying() && playing) {
    nextTrack.play();
  }
}
origin: lycying/c2d-engine

private void playMusic(Music music,boolean loop){
  if(!music.isPlaying()){
    music.setVolume(musicVolume);
    music.setLooping(true);
    music.play();
  }
  
}
 
origin: dingjibang/GDX-RPG

public void act() {
  proxy.act(Gdx.graphics.getDeltaTime());
  music.setVolume(proxy.getColor().a * Game.setting.volume * Game.setting.musicVolume);
}
 
origin: 00-Evan/shattered-pixel-dungeon-gdx

public void play( String assetName, boolean looping ) {
  
  if (isPlaying() && lastPlayed.equals( assetName )) {
    return;
  }
  
  stop();
  
  lastPlayed = assetName;
  lastLooping = looping;
  
  if (!enabled || assetName == null) {
    return;
  }
  
  player = Gdx.audio.newMusic(Gdx.files.internal(assetName));
  player.setLooping(looping);
  player.setVolume(volume);
  player.play();
}

origin: yichen0831/Bomberman_libGdx

public void playMusic(String musicName, boolean isLooping) {
  Music music = assetManager.get(musicPath + musicName);
  music.setVolume(0.6f);
  if (currentMusic.equals(musicName)) {
    music.setLooping(isLooping);
    if (!music.isPlaying()) {
      music.play();
    }
    return;
  }
  stopMusic();
  music.setLooping(isLooping);
  music.play();
  currentMusic = musicName;
}
origin: dsaltares/libgdx-cookbook

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);
}

origin: Catacomb-Snatch/Catacomb-Snatch

@Override
public void startEndMusic() {
  stopBackgroundMusic();
  stopTitleMusic();
  Music endMusic = getMusic(Sounds.END_THEME);
  if (endMusic == null) {
    return;
  }
  if (musicVolume > 0.0f && !endMusic.isPlaying() && !paused) {
    endMusic.setLooping(true);
    endMusic.setVolume(musicVolume);
    endMusic.play();
  }
  TheEndIsPlaying = true;
}
origin: BrentAureli/FlappyDemo

@Override
public void create () {
  batch = new SpriteBatch();
  gsm = new GameStateManager();
  music = Gdx.audio.newMusic(Gdx.files.internal("music.mp3"));
  music.setLooping(true);
  music.setVolume(0.1f);
  music.play();
  Gdx.gl.glClearColor(1, 0, 0, 1);
  gsm.push(new MenuState(gsm));
}
com.badlogic.gdx.audioMusicsetVolume

Javadoc

Sets the volume of this music stream. The volume must be given in the range [0,1] with 0 being silent and 1 being the maximum volume.

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
  • dispose
    Needs to be called when the Music is no longer needed.
  • 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

  • Parsing JSON documents to java classes using gson
  • scheduleAtFixedRate (ScheduledExecutorService)
  • startActivity (Activity)
  • getApplicationContext (Context)
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • Graphics2D (java.awt)
    This Graphics2D class extends the Graphics class to provide more sophisticated control overgraphics
  • Window (java.awt)
    A Window object is a top-level window with no borders and no menubar. The default layout for a windo
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • GregorianCalendar (java.util)
    GregorianCalendar is a concrete subclass of Calendarand provides the standard calendar used by most
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Top 12 Jupyter Notebook extensions
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