简体   繁体   中英

Java - Sound Effects Doesn't Play

I have a program which plays audio but when I need to play a different audio file it does play (and there is no mistake in the location/spelling ).

    if ((getCoordinatesOfDuplicates() == null) && (getEmptyCellsCount() == 0)) {

        try {
            java.applet.AudioClip clip =
                    java.applet.Applet.newAudioClip(
                    new java.net.URL("file:src//audio/applause2.wav"));

            clip.play();
        } catch (java.net.MalformedURLException murle) {
            System.out.println(murle);
        }
        System.out.println("Well Done");

    } else  {
        try {
            java.applet.AudioClip clip =
                    java.applet.Applet.newAudioClip(
                    new java.net.URL("file:src//audio/shutoff.wav"));

            clip.play();
        } catch (java.net.MalformedURLException murle) {
            System.out.println(murle);
        }
        System.out.println("You did something wrong in the puzzle");

    }

The Applause plays fine but the shutoff doesn't play even though the code is the exactly the same and the "You did something wrong in the puzzle" shows up.

Any Ideas?

Turns out that the all the audio files were corrupted, with the exception of applause2.wav . Getting the non-corrupted files resolved the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM