Hi, everyone,
I apologize if this has been solved, but this is the legacy video-on-keypress code that the user discussed that another video would not play after selecting the first one. The thing is that the logic seems to find another video, but only the first selected plays. I have expanded the clunky boolean logic to 8 clips, and something more elegant is a little beyond me ATM.
So, this is the legacy video player code, expanded to 8 clips. It works, indicates the video number, but does not play any clips except the first one played, I can press the first one played after trying other options, and it will play.
Does the logic get stuck in a state which was created by the first keypress, and does not reset it?
I am building this out as a quick and dirty little video player for an interactive video class I’m teaching.
The reason why I like it is that it seems to try to load other clips without having to play the entire clip then go to the next one, which is what I’d really like to have.
Again, my apologies if this is a famous bit of code that I have expanded on, I think there’s just one flaw in the logic of this thing that is holding back its functioning. Thanks in advance.
import processing.video.*;
Movie theMov;
int VideoPlaying;
boolean Vid1 = false;
boolean Vid2 = false;
boolean Vid3 = false;
boolean Vid4 = false;
boolean Vid5 = false;
boolean Vid6 = false;
boolean Vid7 = false;
boolean Vid8 = false;
//Videos
Movie Video1;
Movie Video2;
Movie Video3;
Movie Video4;
Movie Video5;
Movie Video6;
Movie Video7;
Movie Video8;
//Fim Videos
void setup() {
size(600, 300);
//videos
Video1 = new Movie(this, "1.mp4");
Video2 = new Movie(this, "2.mp4");
Video3 = new Movie(this, "3.mp4");
Video4 = new Movie(this, "4.mp4");
Video5 = new Movie(this, "5.mp4");
Video6 = new Movie(this, "6.mp4");
Video7 = new Movie(this, "7.mp4");
Video8 = new Movie(this, "8.mp4");
//Fim videos
}
void draw() {
toogle();
if (Vid1) {
println("video1");
Video2.stop();
Video3.stop();
Video4.stop();
Video5.stop();
Video6.stop();
Video7.stop();
Video8.stop();
background(0);
Video1.play();
background(0);
image(Video1, 0, 0, width, height);
}
if (Vid2) {
println("video2");
Video1.stop();
Video3.stop();
Video4.stop();
Video5.stop();
Video6.stop();
Video7.stop();
Video8.stop();
background(0);
Video2.play();
image(Video2, 0, 0, width, height);
}
if (Vid3) {
println("video3");
Video1.stop();
Video2.stop();
Video4.stop();
Video5.stop();
Video6.stop();
Video7.stop();
Video8.stop();
background(0);
Video3.play();
image(Video3, 0, 0, width, height);
}
if (Vid4) {
println("video4");
Video1.stop();
Video2.stop();
Video3.stop();
Video5.stop();
Video6.stop();
Video7.stop();
Video8.stop();
background(0);
Video4.play();
image(Video4, 0, 0, width, height);
}
if (Vid5) {
println("video5");
Video1.stop();
Video2.stop();
Video3.stop();
Video4.stop();
Video6.stop();
Video7.stop();
Video8.stop();
background(0);
Video5.play();
image(Video5, 0, 0, width, height);
}
if (Vid6) {
println("video6");
Video1.stop();
Video2.stop();
Video3.stop();
Video4.stop();
Video5.stop();
Video7.stop();
Video8.stop();
background(0);
Video6.play();
image(Video6, 0, 0, width, height);
}
if (Vid7) {
println("video7");
Video1.stop();
Video2.stop();
Video3.stop();
Video4.stop();
Video5.stop();
Video6.stop();
Video8.stop();
background(0);
Video7.play();
image(Video7, 0, 0, width, height);
}
if (Vid8) {
println("video8");
Video1.stop();
Video2.stop();
Video3.stop();
Video4.stop();
Video5.stop();
Video6.stop();
Video7.stop();
background(0);
Video8.play();
image(Video8, 0, 0, width, height);
}
}
void movieEvent(Movie m) {
m.read();
}
void keyPressed() {
//video
if (key == '1') {
VideoPlaying = 1 ;
println(VideoPlaying);
}
if (key == '2') {
VideoPlaying = 2 ;
println(VideoPlaying);
}
if (key == '3') {
VideoPlaying = 3 ;
println(VideoPlaying);
}
if (key == '4') {
VideoPlaying = 4 ;
println(VideoPlaying);
}
if (key == '5') {
VideoPlaying = 5 ;
println(VideoPlaying);
}
if (key == '6') {
VideoPlaying = 6 ;
println(VideoPlaying);
}
if (key == '7') {
VideoPlaying = 7 ;
println(VideoPlaying);
}
if (key == '8') {
VideoPlaying = 8 ;
println(VideoPlaying);
}
//end Video
}
void toogle() {
if (VideoPlaying == 1) {
Vid1 = true;
Vid2 = false;
Vid3 = false;
Vid4 = false;
Vid5 = false;
Vid6 = false;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 2) {
Vid1 = false;
Vid2 = true;
Vid3 = false;
Vid4 = false;
Vid5 = false;
Vid6 = false;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 3) {
Vid1 = false;
Vid2 = false;
Vid3 = true;
Vid4 = false;
Vid5 = false;
Vid6 = false;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 4) {
Vid1 = false;
Vid2 = false;
Vid3 = false;
Vid4 = true;
Vid5 = false;
Vid6 = false;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 5) {
Vid1 = false;
Vid2 = false;
Vid3 = false;
Vid4 = false;
Vid5 = true;
Vid6 = false;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 6) {
Vid1 = false;
Vid2 = false;
Vid3 = false;
Vid4 = false;
Vid5 = false;
Vid6 = true;
Vid7 = false;
Vid8 = false;
}
if (VideoPlaying == 7) {
Vid1 = false;
Vid2 = false;
Vid3 = false;
Vid4 = false;
Vid5 = false;
Vid6 = false;
Vid7 = true;
Vid8 = false;
}
if (VideoPlaying == 8) {
Vid1 = false;
Vid2 = false;
Vid3 = false;
Vid4 = false;
Vid5 = false;
Vid6 = false;
Vid7 = false;
Vid8 = true;
}
}