Hello, so I have the code that follows next, what I pretend is to create a rule where if I press the key "2" it will play the video number 2 , but I don't know how to get it. I have all the videos in the same folder. The names are : video1.mp4 , video2.mp4...etc . I need a rule where I play video 2 by pressing key number 2. Please help me.
Code :
import processing.video.*;
Movie theMov;
boolean isPlaying;
boolean isLooping;
void setup() {
size(600, 300);
theMov = new Movie(this, "C:/Users/Filipe/Documents/Processing/libraries/video/video1.mp4");
theMov.loop(); //plays the movie over and over
isPlaying = true;
isLooping = true;
}
void draw() {
background(0);
image(theMov, mouseX-theMov.width/2, mouseY-theMov.height/4);
}
void movieEvent(Movie m) {
m.read();
}
void keyPressed() {
if (key == 'p') {
// toggle pausing
if (isPlaying) {
theMov.pause();
} else {
theMov.play();
}
isPlaying = !isPlaying;
} else if (key == 'l') {
// toggle looping
if (isLooping) {
theMov.noLoop();
} else {
theMov.loop();
}
isLooping = !isLooping;
} else if (key == 's') {
// stop playing
theMov.stop();
isPlaying = false;
} else if (key == 'j') {
// jump to a random time
theMov.jump(random(theMov.duration()));
}
}