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.
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.