No sound using AudioClip but no error occuring

41 views Asked by At

I have to get a .wav clip working for a college assignment on Java using the AudioClip and Applet. When I use the code seen below, I get no errors, even with the use of a try-catch. Not really sure where I have gone wrong, but any help would be much appreciated!

class PlayMySoundApplication {
    static void playElevatorMusic() {
        try {
            AudioClip sound;
            File file = new File ("elevatorMusic.wav");
            URL wavFile = file.toURI ().toURL ();

            sound = Applet.newAudioClip (wavFile);
            sound.play ();
        } catch (Exception e) {
            e.printStackTrace ();
        }
    }

    public static void main(String[] args) {
        playElevatorMusic ();
    }
}
0

There are 0 answers