We are trying to create an interactive video player, which contains 10 short video files, but it has to have a certain functionality: 1st video playing automatically from beginning. Once it is finished, the user must chose by an arrow click, which video to play next - there's two options. Once chosen option of video is finished to play, next video must start to play automatically. Once this video is done playing, there must be another choice between two other videos, just as the first time, and it goes on, till it ends by 10th video playing automatically.
There's two major problems - after first video being played and first choice being done, third video, that suppose to play automatically, doesn't play and the whole application gets stuck. Also, while the first default video is playing, keys pressed are triggering other two videos to play, meanwhile they suppose to play ONLY when the first video is done playing. To make it more understandable, the structure of video playing order and interactivity points, here's the illustration of it:
We hope we formulate the problem so it is easy to understand. Any help or tips would be highly appreciated.
import processing.video.*;
Movie [] mov = new Movie [10];
Boolean playMovie0 = true;
Boolean playMovie1 = false;
Boolean playMovie2 = false;
Boolean playMovie3 = false;
Boolean playMovie4 = false;
Boolean playMovie5 = false;
Boolean playMovie6 = false;
Boolean playMovie7 = false;
Boolean playMovie8 = false;
Boolean playMovie9 = false;
void setup (){
size (810, 540);
mov [0] = new Movie (this, "Vid0.mp4");
mov [1] = new Movie (this, "Vid1.mp4");
mov [2] = new Movie (this, "Vid2.mp4");
mov [3] = new Movie (this, "Vid3.mp4");
mov [4] = new Movie (this, "Vid4.mp4");
mov [5] = new Movie (this, "Vid5.mp4");
mov [6] = new Movie (this, "Vid6.mp4");
mov [7] = new Movie (this, "Vid7.mp4");
mov [8] = new Movie (this, "Vid8.mp4");
mov [9] = new Movie (this, "Vid9.mp4");
mov[0].play();
}
void draw (){
if (playMovie0 == true){
image(mov[0], 0, 0, width, height);
if (mov[0].time() >= mov[0].duration()){
mov[0].stop();
playMovie0 =false;
}
if (key == CODED){
if (keyCode == LEFT){
playMovie1 = true;
mov[1].play();
image(mov[1], 0, 0, width, height);
} else if (keyCode == RIGHT){
playMovie2 = true;
mov[2].play();
image(mov[2], 0, 0, width, height);
}
}
}
if (mov[1].time() >= mov[1].duration()){
mov[1].stop();
playMovie1 = false;
playMovie3 = true;
} else if (mov[2].time() >= mov[2].duration()){
mov[2].stop();
playMovie2 = false;
playMovie3 = true;
}
if (playMovie0 == false && playMovie1 == false && playMovie2 == false && playMovie3 == true){
mov[3].play();
image(mov[3], 0, 0, width, height);
if (mov[3].time() >= mov[3].duration()){
mov[3].stop();
playMovie3 = false;
}
if (key == CODED){
if (keyCode == LEFT){
playMovie4 = true;
mov[4].play();
image(mov[4], 0, 0, width, height);
} else if (keyCode == RIGHT){
playMovie5 = true;
mov[5].play();
image(mov[5], 0, 0, width, height);
}
}
}
if (mov[4].time() >= mov[4].duration()){
mov[4].stop();
playMovie4 = false;
playMovie6 = true;
} else if (mov[5].time() >= mov[5].duration()){
mov[5].stop();
playMovie5 = false;
playMovie6 = true;
}
if (playMovie0 == false && playMovie1 == false && playMovie2 == false &&
playMovie3 == false && playMovie4 == false && playMovie5 == false && playMovie6 == true) {
mov[6].play();
image(mov[6], 0, 0, width, height);
if (mov[6].time() >= mov[6].duration()){
mov[6].stop();
playMovie6 = false;
}
if (key == CODED){
if (keyCode == LEFT){
playMovie7 = true;
mov[7].play();
image(mov[7], 0, 0, width, height);
} else if (keyCode == RIGHT){
playMovie8 = true;
mov[8].play();
image(mov[8], 0, 0, width, height);
}
}
}
if (mov[7].time() >= mov[7].duration()){
mov[7].stop();
playMovie7 = false;
playMovie9 = true;
} else if (mov[8].time() >= mov[8].duration()){
mov[8].stop();
playMovie8 = false;
playMovie9 = true;
}
if (playMovie0 == false && playMovie1 == false && playMovie2 == false &&
playMovie3 == false && playMovie4 == false && playMovie5 == false &&
playMovie6 == false && playMovie7 == false && playMovie8 == false && playMovie9 == true){
mov[9].play();
image(mov[9], 0, 0, width, height);
}
}
void movieEvent (Movie m)
{
m.read();
}