Yesterday I I found a way to NOT load music files to memory, instead just stream the file directly through the disk, but it only works for a second, take note that making
streamingHint = false;
loads it to memory, which making load times slower, which I don't like to happen... but it fixes the problem...
I do not believe in the saying "if it works, do not touch it", but in regards to optimization, this wasn't the case... but if there is no possible fix, I'm going to switch on something else cuz this lib was so outdated, or just accept loading it to the memory...
here's the code:
package johnkennedypena;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
public class DebugStreamingHint {
Music music;
public DebugStreamingHint() throws SlickException {
music = new Music("resources_/music_/music_.ogg", true);
music.play();
}
public static void main(String[] args) throws InterruptedException, SlickException {
new DebugStreamingHint();
Thread.sleep(100000);
}
}
I'm using Windows... My JDK version was Java 8... I use IntelliJ as IDE...
package johnkennedypena;
import org.lwjgl.Sys;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;
public class DebugStreamingHint {
Music music;
public DebugStreamingHint(String title) throws SlickException {
lastFrame = getTime();
music = new Music("resources_/music_/reminds me of elevators.ogg", true);
music.play();
while (true){
int delta = getDelta();
Music.poll(delta);
}
}
public static void main(String[] args) throws InterruptedException, SlickException {
new DebugStreamingHint("");
}
// making int delta a thing
long lastFrame;
public int getDelta() {
long time = getTime();
int delta = (int) (time - lastFrame);
lastFrame = time;
return delta;
}
public long getTime() {
return (Sys.getTime() * 1000) / Sys.getTimerResolution();
}
}
I figured it out! I found Music.poll(int delta) by digging through the slick2d source.
Thanks @OldTeaOwl.