Im making this game, and i use mediatracker to wait for the images to load.
Is it possible to do the same with sounds?
Thanks.
Im making this game, and i use mediatracker to wait for the images to load.
Is it possible to do the same with sounds?
Thanks.
Is this an application or an applet?
Sound is handled differently in the two.
JK
Sorry,
an applet.
Based on the docs I’d say no, which AFAICS is a bit of an oversite. Audio was pertty primative in the Applet space.
My suggestion is to plkay it ahead of tiem once to make it load… or go to an Applciation and use web start.
Sorry I dotn have any better suggestions.,
If you’re using the Clip class, I have some help for you:
Clip clip = (Clip) AudioSystem.getLine(info);
clip.open(audioFormat, audio, 0, size);
clip.stop();
That’s how I initialize my Clip’s for the first time. Calling that loads it into memory once, which prevents delays in following playbacks. Without it, calling a clip to play for the first time will NOT happen immediately, but instead you’ll have a small delay. Using that code to initialize your Clip will solve that problem.
Clever!
Thanks for the tip!