.wav does not play when using AudioClip from Applet class

D

Domingo

I am trying to write an application that does something every minute, in this case play a .wav file. The code compiles and runs but when I call clip.play(); it does not play, just keeps going. It will also terminate normally.

This is the import piece of the code
+++++++++++++++++++++++++++++++++++++++++
class RemindTask extends TimerTask {
int numWarningBeeps = 3;
AudioClip clip;
public void run() {
try
{
clip = Applet.newAudioClip(new URL("file:C:/work/whack.wav"));
}
catch(MalformedURLException e)
{
e.printStackTrace();
}
if (numWarningBeeps > 0) {
clip.play();
System.out.println("Beep!");
numWarningBeeps--;
} else {
clip.play();
System.out.println("Time's up!");

System.exit(0); //Stops everything
}
}
}
+++++++++++++++++++++++++++++++++++++++

the output is:
Beep!
Beep!
Beep!
Time's up!

you can see where it should play before it prints "Beep!".

Any ideas? Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top