v2.4.0: fixed music not properly pausing if tracks are switched
This commit is contained in:
@@ -150,7 +150,7 @@ public enum Music {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void update(){
|
public synchronized void update(){
|
||||||
if (fadeTotal > 0f){
|
if (fadeTotal > 0f && !paused){
|
||||||
fadeTime += Game.elapsed;
|
fadeTime += Game.elapsed;
|
||||||
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
@@ -217,7 +217,7 @@ public enum Music {
|
|||||||
player = Gdx.audio.newMusic(Gdx.files.internal(track));
|
player = Gdx.audio.newMusic(Gdx.files.internal(track));
|
||||||
player.setLooping(looping);
|
player.setLooping(looping);
|
||||||
player.setVolume(volumeWithFade());
|
player.setVolume(volumeWithFade());
|
||||||
player.play();
|
if (!paused) player.play();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
player.setOnCompletionListener(listener);
|
player.setOnCompletionListener(listener);
|
||||||
}
|
}
|
||||||
@@ -232,14 +232,18 @@ public enum Music {
|
|||||||
trackList = null;
|
trackList = null;
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean paused = false;
|
||||||
|
|
||||||
public synchronized void pause() {
|
public synchronized void pause() {
|
||||||
|
paused = true;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.pause();
|
player.pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void resume() {
|
public synchronized void resume() {
|
||||||
|
paused = false;
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
player.play();
|
player.play();
|
||||||
player.setLooping(looping);
|
player.setLooping(looping);
|
||||||
|
|||||||
Reference in New Issue
Block a user