Switch between two videos

edited February 2016 in Library Questions

Hi everyone, i have used the Loop example of Video librarie of Processing. The idea is basic, i want to move the mouse around X or Y axis and switch between two or more videos which start at the same time. The two videos are in a loop.

The problem that i have is when i switch from video 1 to video 2 or vice versa. The first frame correspond to the last frame that i saw from the video. Seems like keep in buffer the last frame. ¿How can i delete it to make the switch more "clean"?

The code is: (Transit.mov and transit2.mov are the same video from examples, just to see if the switch is clean)

 import processing.video.*;

boolean boton1 = false;
boolean boton2 = false;

Movie movie1;
Movie movie2;

void setup() {
  size(640, 480,P3D);
frameRate(30);
  movie1 = new Movie(this, "transit.mov");
  movie2 = new Movie(this, "transit2.mov");
  movie1.loop();
  movie2.loop();
}


void movieEvent(Movie m) {
  if (m == movie1) {
    movie1.read();
  } else if (m == movie2) {
    movie2.read();
  }
}

void draw() {
      if (boton1 == true) {
       image(movie1, 0, 0, width, height);
    } 
  else if (boton2 == true) {
       image(movie2, 0, 0, width, height);
        } else {
    noFill();
  }

    if (mouseX > 0 && mouseX < 320 && mouseY > 0 && mouseY < 640) {
 boton1= true;
 boton2= false;
     } 
   else if (mouseX > 320 && mouseX < 640 && mouseY > 0 && mouseY <640) {
    boton1= false;
  boton2= true;
    } 

  else{
  boton1= false;
  boton2= false;
  }
}
Tagged:

Answers

Sign In or Register to comment.