FMOD SoundStream errors with Webstart

If this wasn’t webstart, I wouldn’t have a problem with how things are working. I know how to open a sound stream to a wav/mp3, however, once files are loaded out of a jar via webstart things become tricky.

If it were on my hard drive, things would look something like this:


//  Where ref is a valid path to a file.
//  ex)  sounds/backgroundmusic/background.mp3
FSound.FSOUND_Stream_Open(ref, FSound.FSOUND_LOOP_OFF, 0, 0));

Since things are through a jar however, I need to use something like this to get the real path to the file through the jar:


class.getClassLoader().getResourceAsStream(ref);
//or
class.getClassLoader().getResource(ref);

Neither of those options work however. I get a null pointer when referring to the sound stream- which basically indicates that nothing was loaded.

What it comes down to is this- FSound.FSOUND_Stream_Open either takes a string, which is the path to the file, or a bytebuffer.

I cannot figure out any valid permutation of a string that works. class.getClassLoader.getResource(ref) returns a URL object. Converting the URL to a string and passing that doesn’t work. Given this (and many other “toString” options I’ve tried) it would seem that passing a bytebuffer is my only choice. However, I don’t know how to convert a mp3 to a bytebuffer in the format that fmod would need. Any ideas on how to convert it?

Thank you for your time.

Hi,

you dont need to convert your Buffer, passing it
over to FMOD should work. Either you can load
the mp3 complete into memory via NIO, but
beware to allocate more than 64MB per Buffer.

The Classloader code also should work, i often
use this:


    class.getClassLoader().getResourceAsStream(ref);

  • jens

Do note that I haven’t tested fmod with webstart at all - there are still errors in the code. I actually think that the open(bytebuffer) methods may be faulty - I will check up on it eventually…

Yep,

i allready tested serveral things in FMOD, most work.
Open via Buffer i havent tested yet

Did someone successfully made a call to FMOD.create()
within Webstart ?

I allways get a Unable to load fmod.dll Error. i put the fmod in all of my jars, it did’nt work.

  • jens

Mac_Systems:

The problem is that the path returned through class.getClassLoader().getResourceAsStream(ref) is relative to the jar. Java can access the file fine, however, fmod cannot. The String path that fmod requires is different than the one required to get the file out of the jar. Fmod can only recognize normal paths such as “media/sounds/sound.mp3”. To get the file out of a jar, the format is different- something along the lines of: “jarname.jar!media/sounds/sound.mp3” (I don’t know the exact syntax). This is the reason why class.getClassLoader().get… is used to grab files from a jar. Basically, fmod doesn’t know how to get files out of a jar, even if you specifically give it the correct string representation of that file’s location within the jar.

fmod.dll needs to be included in in a native library. Both lwjgl’s lwjgl-fmod.dll and the fmod.dll from fmod.org need to be included. I’ve successfully gotten fmod to create via webstart. Currently I can only play MusicModules since they are the only files I can reasonably convert into a bytebuffer and pass to fmod. I can load/play SoundSamples, but they must be loaded from the modules themselves- I have a method that checks against the mod’s sample names versus a desired filename. The drawback is that you need to know what the filename of the sample is. Unless you’re familliar with mod creation this can be difficult. I’m just lucky I’m a composer :slight_smile: PM me and I can help troubleshoot if you like.

Matzon:

FMUSIC_LoadSong/FMUSIC_LoadSongEx and FSound_SampleOpen via bytebuffer are flawless. I only have problems with FSOUND_SoundStream.

Edit: I take that back. That should read that they work flawless when not in webstart. lwjgl-fmod3.dll seems to not be distributing via webstart. As long as it’s already in the bin directory before webstart is run, things are fine.

See here for an example: http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Announcements;action=display;num=1095349750

You cannot use the file argument version with Webstart, unless you read your mp3 resources first and write them to actual local filesystem files and then pass the paths of those files to FMOD.

Or you need to read the whole thing into a direct ByteBuffer… in which case you’re not actually streaming :wink: But if you’re cunning you can read bits at a time into the buffer and use some fancy callback mechanism from FMOD, right…?

Cas :slight_smile:

I know most of this problematic, i allready made some test, but
the String returned from getResource(ref) points to a URL containing “c:/blaba.jar!/your/inner/path/music.mp3” and Fmod
cannot load this, as it use its internal load mechanism (note the:! ).
I also tried to load it through Buffers, and it did’nt work yet, i will soon dig more into that. Basicly all you have to do is a Threaded reading and stuff that into the Buffer passing it to FMOD. Please note that not all your questions can answered there fmod.org forums may also some good info.

  • jens

Grrrr,

today i made my first runnable webstart fmod player for win,
it was successfully tested by a friend without the nasty copy the dll into /bin dir trick. All native code was stored in a single jar including fmod.dll.
I also added


<property key="java.library.path" value="."/>

into the .jnlp file, and all was good :slight_smile:

Well, after that i expanded my ant script to get also the linux version out of it. Then i added the linux resources into the .jnlp. After that Murphy came up again and i get again this java.lang.UnsatisfiedLinkError: no lwjgl-fmod3 in java.library.path error. Why the heck ?

Last to say i build the lwjgl jar’s out of the CVS (updated last hour).

I know it was running also by a friend of mine, did someone had an idea what’s wong ?

  • jens

Bah missed this thread for a while.

Screw the jar! loading
just use GetResourceAsStream - much easier.
I have created a webstartable StreamPlayerMemory that opens an mp3 file in memory and plays the first 60 seconds of it. The version uses the latest and greates from cvs.
jws demoes: http://matzon.dk/lwjgl/jnlp/
please check out the two fmod demos.
binaries of this build (untested, win32 only) :
http://matzon.dk/lwjgl/builds/lwjgl-win32-0.92.zip

source (including the StreamPlayerMemory):
http://matzon.dk/lwjgl/builds/lwjgl-source-0.92.zip

This version does NOT need the fmod3-lwjgl.dll hack. It works fine when distributed in a jar, alongside fmod.dll

well getting a stream from a jar u would use the
io callbacks if u want to do it properly :wink:

Thx,

i will have a look, if it runs i will post my url too, it should
then also support linux aswell.

  • jens