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.
PM me and I can help troubleshoot if you like.
But if you’re cunning you can read bits at a time into the buffer and use some fancy callback mechanism from FMOD, right…?