We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello everybody,
here I am again, turning to your society with a call for help. I want to make this video installation which incorporates webcam light tracking according to which I want to play certain video clips. I can make the clips start, but that's it, I wish to make video run till the end of its duration and only then play other video which (if) was called also to the end of playback and so on.
import processing.video.*;
Capture cam;
int x, y;
Movie mov;
Movie mov_1;
void setup() {
fullScreen();
//size(1280, 720);
frameRate(24);
background(0);
//println(Capture.list());
cam = new Capture(this, 640, 480, 30);
cam.start();
mov = new Movie(this, "1.MOV");
mov.play();
mov.volume(0);
mov_1 = new Movie(this, "2.MOV");
mov_1.play();
mov_1.volume(0);
imageMode(CENTER);
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
background(0);
if (cam.available()) {
cam.read();
cam.loadPixels();
float maxBri = 50;
int theBrightPixel = 0;
for (int i=0; i<cam.pixels.length; i++) {
if (brightness(cam.pixels[i]) > maxBri) {
maxBri = brightness(cam.pixels[i]);
theBrightPixel = i;
}
}
x = theBrightPixel % cam.width;
y = theBrightPixel / cam.width;
}
image(cam, width/2, height/2);
if (x > 400) {
image(mov, width/2, height/2, 1280, 720);
}
if (x > 200 && x < 400) {
image(mov_1, width/2, height/2, 1280, 720);
}
noStroke();
fill(255, 0, 0);
ellipse(map(x,0, 640, 0, 1366), map(y, 0, 480, 0, 768), 10, 10);
}
Answers
okay, I managed to solve the problem, the thing was really obvious. Just needed to add play() and stop() functions in different place.