.wav does not play when using AudioClip from Applet class

Discussion in 'Java' started by Domingo, Jul 17, 2004.

  1. Domingo

    Domingo Guest

    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.
     
    Domingo, Jul 17, 2004
    #1
    1. Advertisements

  2. Andrew Thompson, Jul 17, 2004
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.