home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.1 KB | 42 lines |
- // Sound.java - Sound support
- //
- // Copyright (C) 1996 by Dale Gass
- // Non-exclusive license granted to MKS, Inc.
- //
-
- import java.lang.*;
- import java.util.*;
- import java.awt.*;
- import java.net.*;
- import java.applet.*;
-
- // Sound - Object for representing, playing sounds
-
- public class Sound {
- static Applet app; // Parent applet
- static String files[] = { // The sounds we use
- "doh.au", "drip.au", "out.au", "hey.au"
- };
- public final static int doh = 0; // Constants names for the sounds
- public final static int drip = 1;
- public final static int out = 2;
- public final static int hey = 3;
- static AudioClip sounds[]; // Loaded sounds stored here
-
- // Preload audio
-
- public static void init(Applet a) {
- app = a;
- URL url = app.getCodeBase();
- sounds = new AudioClip[files.length];
- for (int i=0; i<files.length; i++)
- sounds[i] = app.getAudioClip(url, files[i]);
- }
-
- // Constructor - Play the appropriate sound
-
- public Sound(int which) {
- sounds[which].play();
- }
- }
-