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

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

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

origin: libgdx/libgdx

@Override
public void render () {
  currentPosition = music.getPosition();
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  batch.begin();
  batch.draw(buttons, 0, 0);
  font.draw(batch, (int)currentPosition / 60 + ":" + (int)currentPosition % 60, 365, 35);
  batch.end();
  sliderUpdating = true;
  slider.setValue((currentPosition / songDuration) * 100f);
  sliderUpdating = false;
  stage.act();
  stage.draw();
  if (Gdx.input.justTouched()) {
    if (Gdx.input.getY() > Gdx.graphics.getHeight() - 64) {
      if (Gdx.input.getX() < 64) {
        music.play();
      }
      if (Gdx.input.getX() > 64 && Gdx.input.getX() < 128) {
        music.stop();
      }
      if (Gdx.input.getX() > 128 && Gdx.input.getX() < 192) {
        music.pause();
      }
    }
  }
}
origin: langurmonkey/gaiasky

/**
 * Gets the current play position in seconds
 * @return The play position in seconds
 */
public float getPosition() {
  if (currentMusic == null)
    return 0;
  return currentMusic.getPosition();
}
origin: kbz/SIFTrain

switch (syncMode) {
  case 0: {
    mtime = theSong.getPosition();
    if (mtime <= 0f && !songStarted) {
      time += delta;
    mtime = theSong.getPosition();
    if (mtime <= lastmtime) {
      time += delta;
    mtime = theSong.getPosition();
    if (timeSyncAcc < 0.5f) {
      if (mtime <= lastmtime) {
origin: kbz/SIFTrain

public void back() {
  if (world.started) {
    // if the game was paused and we pressed back again, we skip to the results screen
    if (world.paused) {
      this.done = true;
      this.onCompletion(theSong);
      return;
    }
    world.paused = true;
    if (hasMusic) {
      theSong.pause();
      lastmtime = theSong.getPosition();
      time = lastmtime + world.delay;
      timeSyncAcc = 0;
    }
  }
}
origin: bladecoder/bladecoder-adventure-engine

@Override
public void write(Json json) {
  json.writeValue("fileName", fileName);
  json.writeValue("isPlaying", voice != null && (voice.isPlaying() || isPaused));
  json.writeValue("musicPos", voice != null && (voice.isPlaying() || isPaused) ? voice.getPosition() : 0f);
}
origin: kbz/SIFTrain

@Override
public void render(float delta) {
  Gdx.gl.glClearColor(0, 0, 0, 1);
  Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
  stage.act();
  stage.draw();
  if (theSong != null && theSong.isPlaying() && theSong.getPosition() > newBPosition) {
    theSong.setPosition(newAPosition);
  }
}
origin: bladecoder/bladecoder-adventure-engine

@Override
public void write(Json json) {
  json.writeValue("desc", desc);
  json.writeValue("currentMusicDelay", currentMusicDelay);
  json.writeValue("isPlaying", music != null && (music.isPlaying() || isPaused));
  json.writeValue("musicPos", music != null && (music.isPlaying() || isPaused) ? music.getPosition() : 0f);
  if (volumeTween != null)
    json.writeValue("volumeTween", volumeTween);
}
origin: kbz/SIFTrain

if (aPosition != null)
  theSong.setPosition(aPosition);
lastmtime = theSong.getPosition();
time = lastmtime + world.delay;
timeSyncAcc = 0;
origin: kbz/SIFTrain

theSong.setPosition(aPosition);
theSong.play();
lastmtime = theSong.getPosition();
time = lastmtime + world.delay;
timeSyncAcc = 0;
com.badlogic.gdx.audioMusicgetPosition

Javadoc

Returns the playback position in seconds.

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.
  • 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
  • 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
  • CodeWhisperer 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