-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLJMU_Video_Mouse.pde
More file actions
52 lines (43 loc) · 1.25 KB
/
LJMU_Video_Mouse.pde
File metadata and controls
52 lines (43 loc) · 1.25 KB
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
import processing.video.*;
// this is the number of video files in the data/ directory
int NUMBER_OF_FILES = 5;
// the name of the video files should begin with this
String VIDEO_FILE_PREFIX = "movie";
// the video file extension
String VIDEO_FILE_EXTENSION = ".mp4";
Movie movie;
int counter = 0;
void setup() {
size(640, 360);
movie = new Movie(this, dataPath(VIDEO_FILE_PREFIX+counter+VIDEO_FILE_EXTENSION));
movie.jump(movie.duration());
background(0);
}
void draw() {
if (movie.available() == true) {
movie.read();
}
if (abs(movie.time() - movie.duration()) < 0.1) {
fill(0, 4);
noStroke();
rect(0, 0, width, height);
} else {
background(0);
image(movie, 0, 0);
}
}
void mousePressed() {
if (abs(movie.time() - movie.duration()) < 0.1) {
File f = new File(dataPath(VIDEO_FILE_PREFIX+counter+VIDEO_FILE_EXTENSION));
while (!f.exists ()) {
counter = (counter+1)%NUMBER_OF_FILES;
f = new File(dataPath(VIDEO_FILE_PREFIX+counter+VIDEO_FILE_EXTENSION));
}
movie = new Movie(this, dataPath(VIDEO_FILE_PREFIX+counter+VIDEO_FILE_EXTENSION));
movie.play();
counter = (counter+1)%NUMBER_OF_FILES;
} else {
print("click ignored: ");
println(movie.time() +" out of "+ movie.duration());
}
}