I think the problem is at line " myMoviesIndex = 0;" and also the chain of testing is a bit confused ... well an example says more than a thousand words :) I'm not testing if some one is there as mouse can't be pressed by some ghost, maybe a robot, but not a ghost... so i called nextMovie straight form mousePressed.
- import processing.video.*;
- int maxmyMovies=3; //total # movies
- int myMoviesIndex=0; //initial movie to be displayed
- Movie[] myMovies = new Movie[maxmyMovies] ; //declare array of movies
- boolean movieDone = false;
- void setup( ) {
- size(1280, 720);
- for (int i=0; i<myMovies.length; i++) {
- myMovies[i] = new Movie(this, "comedy"+nf(i, 2)+".mov"); //loading movies into the array
- }
- myMovies[myMoviesIndex].loop(); //play the first movie
- }
- void draw() {
- image(myMovies[myMoviesIndex], 0, 0, 1280, 720); //display one movie
- if (myMovies[myMoviesIndex].time() >= myMovies[myMoviesIndex].duration()) {
- // the current movie is done
- myMovies[myMoviesIndex].stop(); // stop the current movie
- movieDone = true;
- }
- fill(255);
- text(myMovies[myMoviesIndex].time(), 30, 30);
- text(myMovies[myMoviesIndex].duration(), 30, 60);
- }
- void movieEvent(Movie myMovies) {
- myMovies.read(); //read new frames from movie
- }
- void mousePressed() {
- if(movieDone){
- nextMovie();
- movieDone = false;
- }
- }
- void nextMovie() {
- myMovies[myMoviesIndex].stop(); // stop the current movie
- myMoviesIndex=(myMoviesIndex+1) % myMovies.length; //increment movie by one and return to zero once size of array is reached
- myMovies[myMoviesIndex].play(); // play the next movie
- }