summaryrefslogtreecommitdiffstats
path: root/Master/Reference Architectures and Patterns/hjp5/examples/PlaySound.java
blob: dc4a93eceea33810d34d460ac8a6b6cb0642554d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/* PlaySound.java */

import java.net.*;
import java.applet.*;

public class PlaySound
{
  public static void main(String[] args)
  {
    if (args.length >= 1) {
      try {
        URL url = new URL(args[0]);
        AudioClip clip = Applet.newAudioClip(url);
        clip.play();
        try {
          Thread.sleep(10000);
        } catch (InterruptedException e) {
        }
        System.exit(0);
      } catch (MalformedURLException e) {
        System.out.println(e.toString());
      }
    }
  }
}