|
-
Apr 16th, 2009, 03:23 PM
#1
Thread Starter
Addicted Member
[RESOLVED] How can I play sounds in Java?
Im making a game and i want to make a sounds class so i can call different sounds from different classes for example
Sounds.play1upSound();
how can i make a sound class? (for .wav mainly)
thanks
Last edited by MoE70; Apr 16th, 2009 at 06:12 PM.
-
Apr 18th, 2009, 06:26 AM
#2
Re: How can I play sounds in Java?
The following sample code might be helpful. I know java has a sound API but this is the easiest way to play a sound file
Code:
import java.net.MalformedURLException;
public class Test {
public static void main(String[] args) throws MalformedURLException {
java.applet.AudioClip clip = java.applet.Applet
.newAudioClip(new java.net.URL(args[0]));
clip.play();
}
}
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Apr 18th, 2009, 09:34 AM
#3
Thread Starter
Addicted Member
Re: How can I play sounds in Java?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|