We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am trying to display text from a String array onto video clips, where it displays as one string per clip; so when the clip changes, the text changes.
What I have so far isn't working, can someone help me with the logic? This is what I have so far:
PFont font;
String[] posts;
String[] videos = {"1.mov", "2.mov", "3.mov", "4.mov", "5.mov", "6.mov",
"7.mov", "8.mov", "9.mov"};
Movie myMovie;
int a = 0;
int count = 0;
float duration = 0;
float time = 0;
void setup(){
size(displayWidth, displayHeight);
//background(0);
posts = loadStrings("posts.txt");
font = loadFont("HelveticaNeue-Bold-48.vlw");
if (frame != null){
frame.setResizable(true);
}
myMovie = new Movie(this, videos[int(random(videos.length))]);
myMovie.play();
text(posts[int(random(posts.length))], 250, displayHeight - 300);
}
void draw(){
if (a == 0){
image(myMovie, 0, 0);
}
image(myMovie, 0, 0);
float duration = myMovie.duration();
float time = myMovie.time();
if ((duration - time) < 0.1){
myMovie = null;
myMovie = new Movie(this, videos[int(random(videos.length))]);
count++;
myMovie.play();
text(posts[int(random(posts.length))], 250, displayHeight - 300);
}
}
void movieEvent(Movie m){
m.read();
}
Answers
Move the text() display after the image(myMovie, ...) call (why are you calling this twice, BTW?). Otherwise, it will be displayed once (after movie loading) and overwritten by the next movie image.
Oh, and after movie.play(), put in a global variable the
int(random(posts.length))]
part, to use it in the text() call, otherwise it will change on each frame!