[Logo]
Forums Register Login
Playing sound from a jar file
I am having problems trying to access sound resources from my jar file. They reside in the directory "/sounds/" in the jar. I am not able to point to the sound file from my code using a URL.



When i run the code outside of the jar everything is fine. But when i put everything into a jar the URL class is unable to reach the wav file. I have the jar in my classpath. A work around could be to use

AudioClip clip = Applet.newAudioClip(url);
clip.play();

But thats not a solution here because once i switch to clip.play() instead of using audio input stream the audio does not play sometimes when called in quick successions or it waits a long time ( around 2 seconds ) before it plays the clip. Does any one know a way through which i can still access the wav files using an audio input stream ? Or can you suggest a way through which i can improve the performance of clip.play() ?

Any suggestions are welcome.
Hey i figured it out ! I am able to stream sound files with the following code.



Just posting to let people know about this solution.
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards


This thread has been viewed 2725 times.

All times above are in ranch (not your local) time.
The current ranch time is
Jan 16, 2018 14:05:12.