v1.0.1: fixed graphics stutter when tracks are switched

This commit is contained in:
Evan Debenham
2021-08-20 20:13:58 -04:00
parent 46635bbd9c
commit 69f122d449

View File

@@ -29,6 +29,9 @@ import com.watabou.utils.Random;
import java.awt.MediaTracker;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public enum Music {
@@ -130,7 +133,12 @@ public enum Music {
return;
}
stop();
//we do this in a separate thread to avoid graphics hitching while the music is prepared
//FIXME this fixes graphics stutter but there's still some audio stutter, perhaps keep more than 1 player alive?
new Thread(){
@Override
public void run() {
Music.this.stop();
if (trackQueue.isEmpty()){
for (int i = 0; i < trackList.length; i++){
@@ -147,6 +155,8 @@ public enum Music {
play(trackQueue.remove(0), trackLooper);
}
}.start();
}
};
private synchronized void play(String track, com.badlogic.gdx.audio.Music.OnCompletionListener listener){