home *** CD-ROM | disk | FTP | other *** search
- import java.applet.AudioClip;
- import java.net.MalformedURLException;
- import java.net.URL;
-
- class SoundArea extends ImageMapArea {
- URL sound;
- AudioClip soundData;
- boolean hasPlayed;
- boolean isReady = false;
- long lastExit;
- static final int HYSTERESIS = 1500;
-
- public void handleArg(String var1) {
- try {
- this.sound = new URL(super.parent.getDocumentBase(), var1);
- } catch (MalformedURLException var2) {
- this.sound = null;
- }
-
- this.hasPlayed = false;
- }
-
- public void getMedia() {
- if (this.sound != null && this.soundData == null) {
- this.soundData = super.parent.getAudioClip(this.sound);
- }
-
- if (this.soundData == null) {
- System.out.println("SoundArea: Unable to load data " + this.sound);
- }
-
- this.isReady = true;
- }
-
- public void enter() {
- if (!this.isReady) {
- super.parent.showStatus("Loading media file...");
- } else {
- long var1 = System.currentTimeMillis();
- if (Math.abs(var1 - this.lastExit) < 1500L) {
- this.hasPlayed = true;
- } else {
- if (!this.hasPlayed && this.soundData != null) {
- this.hasPlayed = true;
- this.soundData.play();
- }
-
- }
- }
- }
-
- public void exit() {
- if (this.hasPlayed) {
- this.hasPlayed = false;
- this.lastExit = System.currentTimeMillis();
- }
-
- }
- }
-