Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to switch between multiple movies?/Play movie after a movie?

$
0
0

Hello everybody.

I'm new here, so sorry if the question is something easy to solve. I'm working on a project and it doesn't work the way it should. Im selecting an area via a webcam. If something enters the selection (mensaanwezig) it should play a video.

There's playing a video at all times, myMovie 1 (should be looping). When something enters it switches to myMovie 2. When the person leaves/and when the end of myMovie2 has been reached, it should play myMovie3 at full length, regardless if something enters or leaves the area. after myMovie3 happened it should switch back to the start of myMovie 1.

I managed to get myMovie2 to play when somebody enters the area, but it switches back to myMovie 1 immediately when something leaves the area.

Can somebody tell me what i'm missing?

import processing.video.*;

Movie myMovie;
Movie myMovie2;
Movie myMovie3;


int x, y, w=20, h=20 ;
int togglemouse=1;
int H, S, B, Hold, Sold, Bold;
int verschil, threshold=50;
int modeselector=1;
color kleur;
boolean mensaanwezig;
boolean changed = false;

Capture cam;

void setup() {
  size(640, 480);
  //fullScreen();

  myMovie = new Movie(this, "Movie01B.mp4");
  myMovie2 = new Movie(this, "Movie02B.mp4");
  myMovie3 = new Movie(this, "Movie03B.mp4");

  myMovie.loop();
  myMovie2.loop();
  myMovie3.loop();

  cam = new Capture(this, 640, 480, "Logitech Webcam C930e");
  cam.start();
}

void movieEvent(Movie m) {
  m.read();
}

..........................

void projectionmode() {

  if (mensaanwezig ==true) {
    if (changed==false) {
      changed=true;
      myMovie2.jump(0);
    }


    if (myMovie2.time() < /**myMovie2.duration*/ 45) {
      myMovie2.play();
      image(myMovie2, 0, 0);
    } else {
      myMovie3.play();
      image(myMovie3, 0, 0);
      if (myMovie3.time() <= /**myMovie3.duration*/ 45) {
        changed=false;
      }
    }
  } else {
    if (changed==true) {
      changed=false;
    }
    myMovie.play();
    image(myMovie, 0, 0);
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles