I find that Processing 2.0's use of seconds (as opposed to frames) to time a video clip makes it difficult to reach certain logical conditions. I need to add an extra frame (1 second / frames per second) to time() readings for things to work. This sketch will preload your clips and loop them
http://code.google.com/p/simple-cinema/
- import processing.video.*;
- Movie video1, video2, video3;
- boolean playVideo1 = true;
- boolean playVideo2 = false;
- boolean playVideo3 = false;
- void setup() {
- size(500, 500);
- video1 = new Movie(this, "video1.mov");
- video2 = new Movie(this, "video2.mov");
- video3 = new Movie(this, "video3.mov");
- }
- void draw() {
- if (playVideo1 == true) {
- video1.play();
- image(video1, 0, 0);
- //println(video1.time() + "\t" + video1.duration());
- if (video1.time() + .03 >= video1.duration()) {
- video1.stop();
- playVideo1 = false;
- playVideo2 = true;
- }
- }
- if (playVideo2 == true) {
- video2.play();
- image(video2, 0, 0);
- //println(video2.time() + "\t" + video2.duration());
- if (video2.time() + .03 >= video2.duration()) {
- video2.stop();
- playVideo2 = false;
- playVideo3 = true;
- }
- }
- if (playVideo3 == true) {
- video3.play();
- image(video3, 0, 0);
- println(video3.time() + "\t" + video3.duration());
- if (video3.time() + .03 >= video3.duration()) {
- video3.stop();
- playVideo3 = false;
- playVideo1 = true;
- }
- }
- }
- void movieEvent(Movie m) {
- m.read();
- }
http://code.google.com/p/simple-cinema/