home *** CD-ROM | disk | FTP | other *** search
- package sun.applet;
-
- import java.applet.AudioClip;
- import java.io.IOException;
- import java.io.InputStream;
- import java.net.URL;
- import java.net.URLConnection;
- import sun.audio.AudioData;
- import sun.audio.AudioDataStream;
- import sun.audio.AudioPlayer;
- import sun.audio.AudioStream;
- import sun.audio.ContinuousAudioDataStream;
-
- public class AppletAudioClip implements AudioClip {
- URL url;
- AudioData data;
- InputStream stream;
-
- public AppletAudioClip(URL var1) {
- InputStream var2 = null;
-
- try {
- try {
- URLConnection var5 = var1.openConnection();
- var5.setAllowUserInteraction(true);
- var2 = var5.getInputStream();
- this.data = (new AudioStream(var2)).getData();
- } finally {
- if (var2 != null) {
- var2.close();
- }
-
- }
-
- } catch (IOException var9) {
- this.data = null;
- }
- }
-
- public AppletAudioClip(byte[] var1) {
- this.data = new AudioData(var1);
- }
-
- public synchronized void play() {
- this.stop();
- if (this.data != null) {
- this.stream = new AudioDataStream(this.data);
- AudioPlayer.player.start(this.stream);
- }
-
- }
-
- public synchronized void loop() {
- this.stop();
- if (this.data != null) {
- this.stream = new ContinuousAudioDataStream(this.data);
- AudioPlayer.player.start(this.stream);
- }
-
- }
-
- public synchronized void stop() {
- if (this.stream != null) {
- AudioPlayer.player.stop(this.stream);
-
- try {
- this.stream.close();
- } catch (IOException var1) {
- }
- }
- }
-
- public String toString() {
- return this.getClass().toString() + "[" + this.url + "]";
- }
- }
-