Hello, I'm new at Processing and I need some help. I want to start a new art project and a friend showed me that I can do it with Processing. I want to capture live video from the notebook webcam and if somebody presses a key, a video starts to play. And when the key is released, I want to the live capture screen be on top again. I can't figured out how to "kill" that video canvas and let the live capture shows and then to "kill" that live capture canvas and so on... I have two codes. The first, puts the video "layer" on top of the live capture "layer" and when it stops a still image of the video its shown. The second one, viceversa...
Thanks in advance!!
FIRST ONE
import processing.video.*;
Capture cam;
Movie video;
void setup() {
size(640,480);
cam = new Capture(this,640,480,30);
video = new Movie(this,"ex.mp4");
cam.start();
}
void keyPressed() {
video.loop();
cam.stop();
}
void draw() {
if (cam.available()) {
cam.read();
image(cam,0,0);
} else video.read(); {
image(video,0,0);
}
}
void keyReleased() {
video.stop();
cam.start();
}
SECOND ONE
import processing.video.*;
Capture cam;
Movie video;
void setup() {
size(640,480);
cam = new Capture(this,640,480,30);
video = new Movie(this,"ex.mp4");
cam.start();
}
void draw() {
if (cam.available()) {
cam.read();
image(cam,0,0);
}
if (keyPressed == true) {
video.loop();
cam.stop();
image(video,0,0);
} else {
video.stop();
cam.start();
image(cam,0,0);
}
}