Play.java Source code

Java tutorial

Introduction

Here is the source code for Play.java

Source

import java.applet.Applet;
import java.applet.AudioClip;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;

public class Play {
    public static void main(String args[]) {
        try {
            // Loop
            URL url = new URL("http://java.sun.com/applets/other/Hangman/audio/whoopy.au");
            AudioClip clip = Applet.newAudioClip(url);
            clip.loop();
            Thread.sleep(5000);
            //Play
            File file = new File("bark.wav");
            clip = Applet.newAudioClip(file.toURL());
            clip.play();
            Thread.sleep(500);
            System.exit(0);
        } catch (InterruptedException e) {
        } catch (MalformedURLException e) {
        }
    }
}