-
Notifications
You must be signed in to change notification settings - Fork 1
/
Video.pde
106 lines (97 loc) · 1.84 KB
/
Video.pde
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
// Functions for video control and rendering
void moveHead(float _s) {
float cur;
if (moviePath != "") {
cur = myMovie.time();
cur += _s;
cur = constrain(cur, 0, myMovie.duration());
setHead(cur);
}
}
void setHeadPercent(float _s) {
float cur;
if (moviePath != "") {
cur = _s * myMovie.duration();
cur = constrain(cur, 0, myMovie.duration());
myMovie.jump(cur);
headPos = cur;
if (moviePaused) {
myMovie.play();
myMovie.pause();
myMovie.read();
myMovie.jump(cur);
}
} else {
headPos = 0f;
}
}
void setHead(float _s) {
println("setHead " + _s);
float cur;
if (moviePath != "") {
cur = _s;
cur = constrain(cur, 0, myMovie.duration());
myMovie.jump(cur);
headPos = cur;
if (moviePaused) {
headLocked = true;
myMovie.play();
myMovie.pause();
myMovie.read();
myMovie.jump(cur);
}
} else {
headPos = 0f;
}
}
void flipPause() {
if (moviePath != "") {
if (moviePaused) {
play();
} else {
pause();
}
}
}
void pause() {
if (moviePath != "") {
if (!moviePaused) {
println("Pausing...");
headLocked = false;
myMovie.pause();
moviePaused = true;
myMovie.read();
myMovie.jump(headPos);
}
}
}
void play() {
if (moviePath != "") {
if (moviePaused) {
println("Plaing...");
headLocked = false;
myMovie.play();
myMovie.read();
myMovie.volume(movieVol);
moviePaused = false;
keyboardSelect = null;
if (dirty) {
dirty = false;
saveVData();
}
}
}
}
void stop() {
if (myMovie!=null) {
myMovie.stop();
myMovie.dispose();
myMovie = null;
}
}
void setVol(Float _newVol) {
movieVol = constrain(_newVol, 0f, 1f);
if (myMovie != null) {
myMovie.volume(movieVol);
}
}