Hello! I am trying to code something where if one button is pressed then a video will play and when another button is pressed then a different video will play. I tried to stick the videos in a mouseClicked function, but the videos are jumpy if they are not in movieEvent. Can I have an if/else statement in movieEvent? This is the code I have right now.
import processing.video.*;
import processing.sound.*;
// videos
Movie cat;
Movie dog;
// buttons
Button b1; //sad face
Button b2; //happy face
void setup() {
size(500, 500);
cat = new Movie(this, "cat.mp4");
cat.loop();
dog = new Movie(this, "dog.mp4");
dog.loop();
b1 = new Button((width/2-80), (height/2+480), (30), (18), (width/2-80), (width/2-50), (height/2+480), (height/2+498));
b2 = new Button ((width/2-42), (height/2+480), (30), (18), (width/2-42), (width/2-12), (height/2+480), (height/2+498));
}
void draw() {
background(255);
b1.display();
b2.display();
}
void movieEvent() {
// code where cat will play when b1 is pressed and dog will play with b2 is pressed
}
class Button {
color buttonC;
float buttonX1;
float buttonY1;
float buttonW1;
float buttonH1;
float xBound1;
float xBound2;
float yBound1;
float yBound2;
boolean click;
Button(float xPosit, float yPosit, float wid, float he, float xB1, float xB2, float yB1, float yB2) {
//this.buttonC = color (#355C7D);
this.buttonC=#B7B5B5;
this.buttonX1=xPosit;
this.buttonY1=yPosit;
this.buttonW1=wid;
this.buttonH1=he;
this.xBound1=xB1;
this.xBound2=xB2;
this.yBound1=yB1;
this.yBound2=yB2;
this.click = false;
}
void display() {
noStroke();
fill(this.buttonC);
rect(this.buttonX1, this.buttonY1, this.buttonW1, this.buttonH1);
}
boolean IsClicked() {
if (mousePressed == true && mouseX>this.xBound1 && mouseY>this.yBound1 && mouseY<this.yBound2 && mouseX<this.xBound2) {
click=true;
}
return click;
}
}