Video playback + display image when finished
in
Core Library Questions
•
1 month ago
Hey guys,
Im new to processing and loving it.
Just a quick question, here's what I'm trying to do:
Im new to processing and loving it.
Just a quick question, here's what I'm trying to do:
Play a short video clip, after the playback I want to display a random image between 1-10
(eventually i want the program to loop this procedure forever)
The code is working so far, but what it does now, is that it only plays the video till the end and thats it. If i call the random image in the draw-section, then it displays the video and the image immediately. How can I tell the program to display the image AFTER the playback?
Can someone help me a little bit here?
import processing.video.*;
Movie myMovie;
PImage fragment;
int rand;
void setup() {
size(640, 480);
myMovie = new Movie(this, "swan-1.mp4");
myMovie.play();
rand = int(random(0,9)); //HERE YOU CHOOSE BETWEEN 10 DIFFERENT IMAGES
takerandomimage("frag_" + nf(rand, 3) + ".jpg"); //CALL YOUR FUNCTION 'takerandomimage'
//REMEMBER TO NAME YOUR IMAGES "frag_000.jpg"
}
void draw() {
image(myMovie, 0, 0);
}
void movieEvent(Movie m) {
m.read();
}
// THIS IS THE FUNCTION
void takerandomimage(String fn) {
fragment = loadImage(fn); //LOAD RANDOM IMAGE
image(fragment,0,0);//DISPLAY RANDOM IMAGE
}
1