v1.0.1: fixed graphics stutter when tracks are switched
This commit is contained in:
@@ -29,6 +29,9 @@ import com.watabou.utils.Random;
|
|||||||
import java.awt.MediaTracker;
|
import java.awt.MediaTracker;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public enum Music {
|
public enum Music {
|
||||||
|
|
||||||
@@ -130,22 +133,29 @@ public enum Music {
|
|||||||
return;
|
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()){
|
if (trackQueue.isEmpty()){
|
||||||
for (int i = 0; i < trackList.length; i++){
|
for (int i = 0; i < trackList.length; i++){
|
||||||
if (Random.Float() < trackChances[i]){
|
if (Random.Float() < trackChances[i]){
|
||||||
trackQueue.add(trackList[i]);
|
trackQueue.add(trackList[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (shuffle) Collections.shuffle(trackQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!enabled || trackQueue.isEmpty()){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
play(trackQueue.remove(0), trackLooper);
|
||||||
}
|
}
|
||||||
if (shuffle) Collections.shuffle(trackQueue);
|
}.start();
|
||||||
}
|
|
||||||
|
|
||||||
if (!enabled || trackQueue.isEmpty()){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
play(trackQueue.remove(0), trackLooper);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user