summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/VideoControlAction.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/scape/VideoControlAction.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/scape/VideoControlAction.java')
-rw-r--r--NET/worlds/scape/VideoControlAction.java115
1 files changed, 115 insertions, 0 deletions
diff --git a/NET/worlds/scape/VideoControlAction.java b/NET/worlds/scape/VideoControlAction.java
new file mode 100644
index 0000000..e0e79f3
--- /dev/null
+++ b/NET/worlds/scape/VideoControlAction.java
@@ -0,0 +1,115 @@
+package NET.worlds.scape;
+
+import java.io.IOException;
+
+public class VideoControlAction extends Action {
+ private final int play = 1;
+ private final int stop = 2;
+ private int mode = 1;
+ private int repeat = 1;
+ private VideoTexture videoTexture = null;
+ private VideoWall videoWall = null;
+ private static Object classCookie = new Object();
+
+ VideoControlAction() {
+ }
+
+ @Override
+ public Persister trigger(Event e, Persister seqID) {
+ if (!this.getVideoTexture()) {
+ System.out.println("ERROR! Tried to attach VideoControlAction to something other than a Rect with a VideoTexture. or a VideoWall object.");
+ return null;
+ } else {
+ switch (this.mode) {
+ case 1:
+ if (this.videoTexture == null) {
+ this.videoWall.getVideoSurface().play(this.repeat);
+ } else {
+ this.videoTexture.getDirectShow().nPlay(this.repeat);
+ }
+ break;
+ case 2:
+ if (this.videoTexture == null) {
+ this.videoWall.getVideoSurface().stop();
+ } else {
+ this.videoTexture.getDirectShow().nStop();
+ }
+ }
+
+ return null;
+ }
+ }
+
+ private boolean getVideoTexture() {
+ if (this.videoTexture != null) {
+ return true;
+ } else {
+ Object owner = this.getOwner();
+ if (owner != null && owner instanceof Rect) {
+ Rect r = (Rect)owner;
+ this.videoTexture = r.getVideoAttribute();
+ if (this.videoTexture != null) {
+ return true;
+ } else if (owner instanceof VideoWall) {
+ this.videoWall = (VideoWall)owner;
+ return true;
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ @Override
+ public void saveState(Saver s) throws IOException {
+ s.saveVersion(1, classCookie);
+ super.saveState(s);
+ s.saveInt(this.mode);
+ s.saveInt(this.repeat);
+ }
+
+ @Override
+ public void restoreState(Restorer r) throws IOException, TooNewException {
+ switch (r.restoreVersion(classCookie)) {
+ case 0:
+ super.restoreState(r);
+ this.mode = r.restoreInt();
+ break;
+ case 1:
+ super.restoreState(r);
+ this.mode = r.restoreInt();
+ this.repeat = r.restoreInt();
+ }
+ }
+
+ @Override
+ public Object properties(int index, int offset, int pmode, Object value) throws NoSuchPropertyException {
+ Object ret = null;
+ switch (index - offset) {
+ case 0:
+ if (pmode == 0) {
+ ret = IntegerPropertyEditor.make(new Property(this, index, "1=Play, 2=Stop"));
+ } else if (pmode == 1) {
+ ret = new Integer(this.mode);
+ } else if (pmode == 2) {
+ this.mode = (Integer)value;
+ }
+ break;
+ case 1:
+ if (pmode == 0) {
+ ret = IntegerPropertyEditor.make(new Property(this, index, "Repeat count (-1 for infinite)"));
+ } else if (pmode == 1) {
+ ret = new Integer(this.repeat);
+ } else if (pmode == 2) {
+ this.repeat = (Integer)value;
+ }
+ break;
+ default:
+ ret = super.properties(index, offset + 2, pmode, value);
+ }
+
+ return ret;
+ }
+}