Hi! I am trying to use Processing to make a random video generator, so that every time the program runs, a random video is picked from three different arrays (sort of like a random Choose Your Own Adventure). I have successfully solved this without using arrays, but the addition of arrays has resulted in some glitches. A friend helped me add the seq variable and the timer, but the program only plays two clips at a time, and often cuts off the first video before it has finished. Are there any suggestions as to how to get one video in each of the three arrays to play one after another? Thanks for the help, I only dabble in Processing so I’m limited in my knowledge. Have looked at a lot of other topics, but haven’t found one that’s trying to do the same thing.
import processing.video.*;
Movie [] begin = new Movie[3];
Movie [] middle = new Movie[3];
Movie [] end = new Movie[3];
float movieLength;
int timer;
int seq = 0;
int r1, r2, r3;
void setup(){
size(1280, 720);
frameRate(30);
begin[0] = new Movie (this, "begin/A Few Good Men.mov");
begin[1] = new Movie(this, "begin/Beetlejuice.mov");
begin[2] = new Movie(this, "begin/Catch me if you can.mov");
middle [0] = new Movie(this, "middle/Inside Out.mov");
middle [1] = new Movie(this, "middle/Incredibles 2.mov");
middle [2] = new Movie(this, "middle/Ghostbusters.mov");
end [0] = new Movie(this, "end/Love And Other Drugs.mov");
end [1] = new Movie(this, "end/The Jackal.mov");
end [2] = new Movie(this, "end/Manhattan.mov");
timer = second();
background(0);
r1 = int(random(0,2));
r2 = int(random(0,2));
r3 = int(random(0,2));
}
void draw(){
if(seq == 0){
int m = second() - timer;
image(begin[r1], 0, 0, 1280, 720);
begin[r1].play();
int duration = int(begin[r1].duration());
if(m >= duration){
begin[r1].stop();
print("stopped");
seq = 1;
timer = second();
}
}
else if (seq == 1){
int m = second() - timer;
image(middle[r2], 0, 0, 1280, 720);
middle[r2].play();
int duration = int(middle[r2].duration());
if (m >= duration){
middle[r2].stop();
print("stopped");
timer = second();
seq = 2;
}
}
else if (seq == 2){
int m = second() - timer;
image(end[r3], 0, 0, 1280, 720);
end[r3].play();
int duration = int(end[r3].duration());
if (m >= duration){
end[r3].stop();
print("stopped");
timer = second();
seq = 0;
}
}
}
void movieEvent(Movie m) {
m.read();
}