Slick2D 奇怪的错误,Music(String ref, boolean streamingHint) 只工作一秒钟然后停止

Slick2D weird bug, Music(String ref, boolean streamingHint) only works for a second then stops

昨天我 我找到了一种不将音乐文件加载到内存的方法,而是直接通过磁盘 stream 文件,但它只能工作一秒钟,请注意 making

streamingHint = false;

将其加载到内存中,这使加载时间变慢,我不希望发生这种情况...但它解决了问题...

我不相信“如果有用,就不要碰它”这句话,但在优化方面,情况并非如此……但如果没有可能的解决办法,我会去打开其他东西因为这个库太过时了,或者只是接受将它加载到内存中...

video proof

代码如下:

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);
    }
}

我正在使用 Windows...我的 JDK 版本是 Java 8...我使用 IntelliJ 作为 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();
    }
}

我想通了!我通过挖掘 slick2d 源找到了 Music.poll(int delta)。

谢谢@OldTeaOwl