简体   繁体   中英

Cant' load .ogg music files into Eclipse project in Slick2D

Hi I'm very new here and I,m learning how to use Slick2D game library. I'm using Eclipse Luna IDE for coding. Everything was working fine till now but when I tried to load a music with ".ogg" extension, the problem occured.

I try to load a music by this line of code music = new Music( "res/game_music.ogg" );

An exception occurs like this,

AL lib: FreeContext: (000000000E2F08A0) Deleting 64 Source(s)
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jorbis/Info
    at org.newdawn.slick.openal.OggInputStream.<init>(OggInputStream.java:35)
    at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:311)
    at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
    at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
    at org.newdawn.slick.Music.<init>(Music.java:135)
    at org.newdawn.slick.Music.<init>(Music.java:74)
    at main.Game.init(Game.java:48)
    at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
    at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
    at main.Game.main(Game.java:33)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jorbis.Info
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 10 more

I can assure you that 1. I've looked on the internet for enough time to find a solution and surprisingly I could not find anything helpful even though many other people have faced similar problems. 2. the "res/game_music.ogg" is in the right place. I am new here and can't include pictures in my question otherwise I would include a screenshot to show that the file is in right place.

Important note: I faced some confusions when setting up the project. I don't want to lengthen my question now so I'm not talking about that now. But if anyone here tells me that my problem here is related to lwjgl.jar/slick.jar/native files etc. then I will include it. At this moment just know that before trying to load music, every other render/update thing worked fine.

Would appreciate any helpful answer.

You have to include 2 jars in your project.

Download the Slick2D archive , and then add lib/jogg-0.0.7.jar and lib/jorbis-0.0.15.jar to your project.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM