在OSX上加载MP3时出现奇怪错误

时间:2014-03-19 22:16:20

标签: java audio jlayer

我正在使用tritonus,mp3spi和jl1.0.1。当我尝试在Eclipse(OSX)中调试或运行时,它会抛出NullPointerException。但在Windows上它工作得很好。有什么建议?我很乐意让这个工作来开发跨平台。

使它变得奇怪的部分仅限于Mac。

java.lang.NullPointerException 
    at com.plake.audio.JukeBox.load(JukeBox.java:26) 
    at com.plake.gamestate.MenuState.<init>(MenuState.java:59) 
    at com.plake.gamestate.GameStateManager.loadState(GameStateManager.java:85) 
    at com.plake.gamestate.GameStateManager.<init>(GameStateManager.java:49) 
    at com.plake.main.GamePanel.init(GamePanel.java:54) 
    at com.plake.main.GamePanel.run(GamePanel.java:59) 
    at java.lang.Thread.run(Thread.java:695)

点唱机:

  public static void load(final String s, final String n) {
    try {
        if (JukeBox.clips.get(n) != null) {
            return;
        }
        final AudioInputStream ais = AudioSystem.getAudioInputStream(JukeBox.class.getResourceAsStream(s));
        final AudioFormat baseFormat = ais.getFormat();
        final AudioFormat decodeFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false);
        final AudioInputStream dais = AudioSystem.getAudioInputStream(decodeFormat, ais);
        final Clip clip = AudioSystem.getClip();
        clip.open(dais);
        JukeBox.clips.put(n, clip);
    }
    catch (Exception e) {
        e.printStackTrace();
    }
}

错误发生在if语句

之后

0 个答案:

没有答案