Hi, I’m using an IR sensor to play a video in Processing on Raspberry Pi.
mouth0 = a video of a closed mouth
mouth1 = a video of the mouth singing
Once triggered, I want mouth1 to play until the entire clip finishes, but with the current code, it only keeps playing the video while my hand is actively triggering the sensor. When I remove my hand, it stops playing immediately.
How can I keep the clip playing until it’s done?
Thank you.
import processing.video.*;
import processing.io.*;
Movie mouth0, mouth1;
boolean m0 = true;
boolean m1 = false;
int VideoPlaying;
void setup() {
noCursor();
background(0);
GPIO.pinMode(17, GPIO.INPUT_PULLUP);
size(480, 270);
background(0);
mouth0 = new Movie(this, "mouth0.mov");
mouth1 = new Movie(this, "mouth1.mov");
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
if (GPIO.digitalRead(17) == GPIO.LOW) {
VideoPlaying = 1 ;
println(VideoPlaying);
}else{
VideoPlaying = 0 ;
println(VideoPlaying);
}
toogle();
//println("m0:"+m0);
//println("m1:"+m1);
if (m1) {
mouth0.stop();
mouth1.play();
image(mouth1, 0, 0, width, height);
println("mouth1 playing");
if (abs(mouth1.duration()-mouth1.time()) < .05){
m1 = false;
mouth1.stop();
VideoPlaying = 0;
}
}
if (m0) {
mouth0.loop();
image(mouth0, 0, 0, width, height);
println("mouth0 playing");
}
}
void toogle() {
if (VideoPlaying == 0) {
m0 = true;
m1 = false;
}
if (VideoPlaying == 1) {
m0 = false;
m1 = true;
}
}