Sign in to follow this  
Coder101

Sounds in Java Application

Recommended Posts

Hi i have a simple scroller shooter with several classes with the ships being in the a panel and the panel is in a frame now how do can I make it play a sound and where should the code be? The internat has been most unhelpfull with the Applet.somethingorother.play

Share this post


Link to post
Share on other sites
<disclaimer>I don't have much experience with this myself and everything i say here is strictly from the API </disclaimer>


I can see two possible ways of doing this from the API (both of which may or may not work).

The first is using the Play(URL url) method from the applet class. This seems like as long as your are giving it the correct path it should play the audio file you want.

If that doesn't work, I'd check out the newAudioClip(URL url) or getAudioClip(URL url) methods to instantiate an AudioClip object and then use the AudioClip class's play (or loop) method to work the audio.

API just in case you weren't looking at it...but I'm sure you've had a look.

Hope this works,
Jeff

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this