home *** CD-ROM | disk | FTP | other *** search
- package sun.applet;
-
- import java.applet.AudioClip;
- import java.io.ByteArrayInputStream;
- import java.io.IOException;
- import java.io.InputStream;
- import java.lang.reflect.Constructor;
- import java.net.URL;
- import java.net.URLConnection;
- import java.security.AccessController;
- import java.security.PrivilegedActionException;
-
- public class AppletAudioClip implements AudioClip {
- private static Constructor acConstructor = null;
- private URL url = null;
- private AudioClip audioClip = null;
- boolean DEBUG = false;
-
- public AppletAudioClip(URL var1) {
- this.url = var1;
-
- try {
- InputStream var2 = var1.openStream();
- this.createAppletAudioClip(var2);
- } catch (IOException var3) {
- if (this.DEBUG) {
- System.err.println("IOException creating AppletAudioClip" + var3);
- }
- }
-
- }
-
- public AppletAudioClip(URLConnection var1) {
- try {
- this.createAppletAudioClip(var1.getInputStream());
- } catch (IOException var3) {
- if (this.DEBUG) {
- System.err.println("IOException creating AppletAudioClip" + var3);
- }
- }
-
- }
-
- public AppletAudioClip(byte[] var1) {
- try {
- ByteArrayInputStream var2 = new ByteArrayInputStream(var1);
- this.createAppletAudioClip(var2);
- } catch (IOException var3) {
- if (this.DEBUG) {
- System.err.println("IOException creating AppletAudioClip " + var3);
- }
- }
-
- }
-
- void createAppletAudioClip(InputStream var1) throws IOException {
- if (acConstructor == null) {
- if (this.DEBUG) {
- System.out.println("Initializing AudioClip constructor.");
- }
-
- try {
- acConstructor = (Constructor)AccessController.doPrivileged(new 1(this));
- } catch (PrivilegedActionException var4) {
- if (this.DEBUG) {
- System.out.println("Got a PrivilegedActionException: " + var4.getException());
- }
-
- throw new IOException("Failed to get AudioClip constructor: " + var4.getException());
- }
- }
-
- try {
- Object[] var2 = new Object[]{var1};
- this.audioClip = (AudioClip)acConstructor.newInstance(var2);
- } catch (Exception var3) {
- throw new IOException("Failed to construct the AudioClip: " + var3);
- }
- }
-
- public synchronized void play() {
- if (this.audioClip != null) {
- this.audioClip.play();
- }
-
- }
-
- public synchronized void loop() {
- if (this.audioClip != null) {
- this.audioClip.loop();
- }
-
- }
-
- public synchronized void stop() {
- if (this.audioClip != null) {
- this.audioClip.stop();
- }
-
- }
- }
-