Evil Monkey wrote:
> Hi there, well my java game is nearly finished.
>
> thanks for the advice the people on this board provided.
>
> I have one more little question concerning sound..
>
> i am using the following code for my applciation but getting no sound..
>
> //amongst others...
>
> import java.io.File;
> import java.applet.Applet;
> import java.applet.AudioClip;
> import java.net.MalformedURLException;
>
>
> AudioClip clip; //class variable
>
> public void sound ()
> {
> File file = new File ("bomb.wav");
>
> try
> {
> clip=Applet.newAudioClip(file.toURL());
> }
> catch(MalformedURLException mfe){}
> }
>
>
> //and elsewhere in my code..
>
> clip.play();
>
> can anyone see where I am going wrong ?? I simply want to play a small sound
> when a graphical object hits another graphical object.
>
> //it seems to be unable to find the file.. what syntax should i use to tell
> it where to look?? e.g. h:\sound is my sounds source directory
>
> any suggestions?? the speakers are up and working is there something obvious
> im missing??
>
>
> many thanks
>
Well, for a start, you're asking for head-scratching if you do this:
catch(MalformedURLException mfe){}
Why not actually indicate something if this exception is thrown? It may
be getting thrown and you'd have no idea.
aex
|