summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/ASFSoundPlayer.java
diff options
context:
space:
mode:
Diffstat (limited to 'NET/worlds/scape/ASFSoundPlayer.java')
-rw-r--r--NET/worlds/scape/ASFSoundPlayer.java108
1 files changed, 108 insertions, 0 deletions
diff --git a/NET/worlds/scape/ASFSoundPlayer.java b/NET/worlds/scape/ASFSoundPlayer.java
new file mode 100644
index 0000000..1f87064
--- /dev/null
+++ b/NET/worlds/scape/ASFSoundPlayer.java
@@ -0,0 +1,108 @@
+package NET.worlds.scape;
+
+import NET.worlds.network.URL;
+
+public class ASFSoundPlayer extends MCISoundPlayer {
+ float ang;
+ float dist;
+ float vol;
+ int leftToRepeat;
+ int running;
+ private URL url;
+
+ public ASFSoundPlayer(Sound owner) {
+ super(owner);
+ }
+
+ @Override
+ public boolean open(float volume, float stopDist, boolean atten, boolean pan) {
+ return true;
+ }
+
+ @Override
+ public void close() {
+ this.stop();
+ }
+
+ @Override
+ public boolean position(Point3Temp cam, Point3Temp obj, Point3Temp out, Point3Temp up) {
+ Point3Temp toObj = Point3Temp.make(obj).minus(cam);
+ Point3Temp right = Point3Temp.make(out).cross(up);
+ float y = toObj.dot(out);
+ float x = toObj.dot(right);
+ this.ang = (float)(Math.atan2(y, x) / Math.PI);
+ this.dist = toObj.length();
+ return this.setVolume(this.vol);
+ }
+
+ @Override
+ public boolean setVolume(float v) {
+ return true;
+ }
+
+ @Override
+ public int getState() {
+ this.gotFinished(!ASFThread.isActive());
+ return this.running != 0 ? 0 : 1;
+ }
+
+ @Override
+ public synchronized void start(int repeatCount) {
+ if (repeatCount == 0) {
+ this.running = 0;
+ } else {
+ this.leftToRepeat = repeatCount;
+ if (this.leftToRepeat > 0) {
+ this.leftToRepeat--;
+ }
+
+ this.running = 1;
+ URL myURL = this.owner == null ? this.url : this.owner.getURL();
+ this.running = 2;
+ new ASFThread(myURL, this);
+ }
+ }
+
+ @Override
+ public synchronized void start(URL u) {
+ this.url = u;
+ this.start(1);
+ }
+
+ public static void pauseSystem() {
+ ASFThread.pauseASF();
+ WavSoundPlayer.pauseSystemExceptASF();
+ }
+
+ public static void resumeSystem() {
+ ASFThread.resumeASF();
+ WavSoundPlayer.resumeSystemExceptASF();
+ }
+
+ @Override
+ synchronized void gotFinished(boolean f) {
+ if (f && this.running == 2) {
+ this.start(this.leftToRepeat);
+ }
+ }
+
+ @Override
+ public synchronized void stop() {
+ this.leftToRepeat = 0;
+ ASFThread.stopASF();
+ }
+
+ @Override
+ public void volume(float left, float right) {
+ }
+
+ public static synchronized boolean isActive() {
+ return ASFThread.isActive();
+ }
+
+ static synchronized void shutdown() {
+ ASFThread.stopASF();
+ }
+
+ static native boolean nativePlay(String var0);
+}