@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(); } } } }
/** * Gets the current play position in seconds * @return The play position in seconds */ public float getPosition() { if (currentMusic == null) return 0; return currentMusic.getPosition(); }
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) {
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; } } }
@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); }
@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); } }
@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); }
if (aPosition != null) theSong.setPosition(aPosition); lastmtime = theSong.getPosition(); time = lastmtime + world.delay; timeSyncAcc = 0;
theSong.setPosition(aPosition); theSong.play(); lastmtime = theSong.getPosition(); time = lastmtime + world.delay; timeSyncAcc = 0;