Slick Forums

Discuss the Slick 2D Library
It is currently Wed Jun 19, 2013 2:58 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
PostPosted: Thu Feb 16, 2012 4:55 pm 
Offline

Joined: Thu Feb 16, 2012 4:36 pm
Posts: 4
Hello. Sorry for what could potentially be a newbie question. I'm exporting my java game to a jar, and Slick's AudioLoader doesn't seem to like that. Inside the IDE, everything loads fine, but outside the IDE, audio only refuses to work. I am using the same root folder for the input stream as graphics (which work), the same natives location, the same everything, but it only loads graphics (removing audio from being loaded makes the program launch without audio just fine, with slick-loaded textures!). I've tried directly specifying the natives location in the launch arguments, even. I am using jorbis properly. It just refuses to load audio outside eclipse.

titlemusic=AudioLoader.getAudio("OGG", ResourceLoader.getResourceAsStream("./resources/title.ogg"));
^ the above line crashes my program with no exceptions thrown, but ONLY outside the IDE, and graphics load fine using ResourceLoader. I have tried this with multiple formats and audio files, they all do this.

Any help? Can I use a different method to load my Audio?


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 5:50 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
Run the JAR from the console, and let us know what it says when the program crashes.

Also, for the path, usually it's easier to write it like so:
"resources/tile.ogg"

Then you place the "resources" folder inside the "src" folder.


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 10:37 pm 
Offline

Joined: Thu Feb 16, 2012 4:36 pm
Posts: 4
Thanks for the response. I ended up fixing this within an hour after posting the topic by adding the following lines as the first two calls within my entire program. I found them within the basic tutorials for slick, but I would have never known to look there if I hadn't assumed i was making a newbie error. It turns out slick is dependant on this for only audio, graphics load the natives from the same folder as the jar without these lines, but audio doesn't. (perhaps audio is deprecated behind texture loading somehow?). Anyway, this should either be remodeled or put into the very basic lwjgl tutorial.

System.setProperty("org.lwjgl.librarypath", new File(new File(System.getProperty("user.dir"), "native"), LWJGLUtil.getPlatformName()).getAbsolutePath());
System.setProperty("net.java.games.input.librarypath", System.getProperty("org.lwjgl.librarypath"));


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 10:46 pm 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
You shouldn't need to manually set the native location with System.setProperty; instead, you should distribute your game with the native files in the same folder. Or, use a tool like JarSplice to pack the natives + libraries into a single, executable JAR.


Top
 Profile  
 
PostPosted: Thu Feb 16, 2012 11:32 pm 
Offline

Joined: Thu Feb 16, 2012 4:36 pm
Posts: 4
I have been packaging the natives in the same folder as the jar, and only the graphics natives are read properly. Once I used this and put the natives in subfolders, audio started working alongside graphics. Note that the entire time, graphics natives have been working, and the entire time, audio natives have been in the exact same folder. My guess is that something within the audioloader is not reading the default library location properly, but it starts working once you set it manually.


Top
 Profile  
 
PostPosted: Fri Feb 17, 2012 12:34 am 
Offline
Slick Zombie

Joined: Sat Jan 27, 2007 7:10 pm
Posts: 1477
AudioLoader simply decodes data from an input stream into PCM format; so I doubt the problem lies with Slick.

Your solution is more of a hack/workaround and could lead to problems down the road. If the user runs your JAR from a different working directory (i.e. runs JAR from different shell location) then your app won't work. And the results might be unpredictable on some systems (i.e. Android).

Make sure you are using -Djava.library.path when running your JAR from outside of Eclipse.


Top
 Profile  
 
PostPosted: Fri Feb 17, 2012 1:43 am 
Offline

Joined: Thu Feb 16, 2012 4:36 pm
Posts: 4
That was the first thing I tried, it was still only the graphics working.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group