Computer Science Canada Java Jeopardy Game Help with Sound |
Author: | AshleyI [ Fri Jan 19, 2007 9:11 pm ] | ||
Post subject: | Java Jeopardy Game Help with Sound | ||
Hi, Can someone kindly help me and show me how I can play an audio clip at the beginning of my game. I already have the audio clip and it's a URL. I only have basic knowledge in Java. I tried searching and this is what I found so far:
I pasted this code in a seperate method; and changed the URL link and I get 24 errors ![]() ![]() P.S. Yes, This topic had been posted before and there is the same link given to the code.. but no explanation. And I absolutely have no idea what to do next.. Thanks, Ashley. [/url] Edit: wtd added code tags |
Author: | HellblazerX [ Sat Jan 20, 2007 5:36 pm ] |
Post subject: | Re: Java Jeopardy Game Help with Sound |
AshleyI wrote: I pasted this code in a seperate method; and changed the URL link and I get 24 errors
![]() ![]() All variables must be declared, or else they cannot be used. As for AudioFormat, it's a class, and that you must import from the javax.sound.sampled package. Unfortunately, I don't understand too much about the javax.sound.sampled package, but I do remember that it was really confusing and complicated, and I ended up using the Applet class's AudioClip interface for my own project. If your program is an applet, you can use your applet's built-in method getAudioClip (url), or use Applet's static method, Applet.newAudioClip (url), to create a new AudioClip object, and you don't have to worry about formats or anything else like that. |
Author: | AshleyI [ Sat Jan 20, 2007 7:13 pm ] |
Post subject: | RE:Java Jeopardy Game Help with Sound |
Unfortunately, my game is created in consoles. And I tried to import javax.sound.sampled.*; and I am getting an error: Import refers to a missing package. Does anyone know anything about that? And how do I declare other variables? The Q may sound stupid, but I have no idea what I m doing anymore. ![]() Ashley. |
Author: | HellblazerX [ Sun Jan 21, 2007 12:29 pm ] | ||
Post subject: | Re: RE:Java Jeopardy Game Help with Sound | ||
AshleyI wrote: Unfortunately, my game is created in consoles.
Hmmmm, that certainly is a problem. I don't know much about consoles, mainly cuz I don't use them, but I do know the RTP's console uses its own separate library, and you'd have to find the directory where the library is located, and add in the packages in manually. I would recommend, however, that you use the Applet package. I'm pretty sure your console should have it. AshelyI wrote: And how do I declare other variables
You declare variables in a line by first stating the type of object they'll be referring to, and the name of the variable:
AudioInputStream would be the type of object that the variable is referring to, and stream is the name of the variable. |