home *** CD-ROM | disk | FTP | other *** search
/ Sky at Night 2007 June / SAN CD 6-2007 CD-ROM 25.iso / pc / Software / AstroGrav_Win / Java / jre1.6.0 / lib / rt.jar / sun / applet / AppletAudioClip.class (.txt) < prev    next >
Encoding:
Java Class File  |  2006-11-29  |  1.7 KB  |  82 lines

  1. package sun.applet;
  2.  
  3. import com.sun.media.sound.JavaSoundAudioClip;
  4. import java.applet.AudioClip;
  5. import java.io.ByteArrayInputStream;
  6. import java.io.IOException;
  7. import java.io.InputStream;
  8. import java.net.URL;
  9. import java.net.URLConnection;
  10.  
  11. public class AppletAudioClip implements AudioClip {
  12.    private URL url = null;
  13.    private AudioClip audioClip = null;
  14.    boolean DEBUG = false;
  15.  
  16.    public AppletAudioClip(URL var1) {
  17.       this.url = var1;
  18.  
  19.       try {
  20.          InputStream var2 = var1.openStream();
  21.          this.createAppletAudioClip(var2);
  22.       } catch (IOException var3) {
  23.          if (this.DEBUG) {
  24.             System.err.println("IOException creating AppletAudioClip" + var3);
  25.          }
  26.       }
  27.  
  28.    }
  29.  
  30.    public AppletAudioClip(URLConnection var1) {
  31.       try {
  32.          this.createAppletAudioClip(var1.getInputStream());
  33.       } catch (IOException var3) {
  34.          if (this.DEBUG) {
  35.             System.err.println("IOException creating AppletAudioClip" + var3);
  36.          }
  37.       }
  38.  
  39.    }
  40.  
  41.    public AppletAudioClip(byte[] var1) {
  42.       try {
  43.          ByteArrayInputStream var2 = new ByteArrayInputStream(var1);
  44.          this.createAppletAudioClip(var2);
  45.       } catch (IOException var3) {
  46.          if (this.DEBUG) {
  47.             System.err.println("IOException creating AppletAudioClip " + var3);
  48.          }
  49.       }
  50.  
  51.    }
  52.  
  53.    void createAppletAudioClip(InputStream var1) throws IOException {
  54.       try {
  55.          this.audioClip = new JavaSoundAudioClip(var1);
  56.       } catch (Exception var3) {
  57.          throw new IOException("Failed to construct the AudioClip: " + var3);
  58.       }
  59.    }
  60.  
  61.    public synchronized void play() {
  62.       if (this.audioClip != null) {
  63.          this.audioClip.play();
  64.       }
  65.  
  66.    }
  67.  
  68.    public synchronized void loop() {
  69.       if (this.audioClip != null) {
  70.          this.audioClip.loop();
  71.       }
  72.  
  73.    }
  74.  
  75.    public synchronized void stop() {
  76.       if (this.audioClip != null) {
  77.          this.audioClip.stop();
  78.       }
  79.  
  80.    }
  81. }
  82.