1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
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;
}
}
|