I have some wavs that I want to play via an JApplet. I am using javax.sound.sample. The wav files play fine when included in the jar. But they are large, and make the load time for the JApplet rather long. (With audio, start takes 3 minutes, without audio, start takes 10 seconds!)
A friend suggested that there might be a way to store and access the audio files on the server rather than include them in the jar. I've tried putting the audio files in a sub directory of the codebase, and various ways to input the files, but am not having any luck.
This works, when the wav files are part of the jar:
In this case, the audio files are in a subdirectory off of the a package where I have the playback code.
gongWav is a
string, such as "a4.wav". An example can be heard here:
http://www.hexara.com/Audio/a4.wav
I tried using the same code with an absolute address for the audio, as in:
I also tried loading as a stream from a URL like this:
In both cases, the result was silence.
Part of the difficulty here is that I don't have a lot of technique for debugging
Applets. It kind of has to be done at that location, as the problem is location-specific. Normally, I use Eclipse and a lot of System.out.println() statements, and that suffices, or occasionally I'll run the debugger. But I don't see how that can help me here. I'm not even clear how one finds the System.out.println() output when running code from the Browser.
If you'd like to see/hear the app, it is a puzzle game in progress, my first 2D game attempt with
Java, and there is a lot to do with it still. Like, include directions as to how to play!
www.hexara.com/game.html (takes about 3 minutes to load, but has audio within the jar)
www.hexara.com/gameNS.html (NS=no sound, loads in about 10 seconds)
If you are intrigued and want instructions, I will be happy to provide them.
Anyway, it would be pretty awesome if there was a way to use my bulky sound files in the program without affecting the start time so severely. I'm trying to avoid using MP3 or other lossy compression formats.
Many thanks!