Created
December 19, 2015 02:55
-
-
Save drart/e9eec09d929353d0f7ee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.video.*; | |
Movie[] videos = new Movie[4]; | |
boolean eventhappens = true; | |
boolean videoIsPlaying = false; | |
int eventnumber=0; | |
float movieEndDuration = 0.029719; | |
int[] events = {}; | |
void setup(){ | |
size(720,480); | |
videos[0] = new Movie(this, "030600_hexagon.mov"); | |
videos[1] = new Movie(this, "030500_trapezoid.mov"); | |
videos[2] = new Movie(this, "030400_square.mov"); | |
videos[3] = new Movie(this, "030300_sawtooth.mov"); | |
} | |
void draw(){ | |
background(100); | |
// if the movie still has time then keep showing it | |
// http://stackoverflow.com/questions/31832499/playing-multiple-videos-in-processing | |
if( videoIsPlaying ){ | |
image(videos[eventnumber],0,0,720,480); | |
} | |
} | |
void movieEvent(Movie m){ | |
m.read(); | |
if (m.time()+movieEndDuration >= m.duration() ){ | |
videoIsPlaying = false; | |
if(events.length > 0){// there are more videos in the queue | |
eventnumber = events[0]; | |
//videos[eventnumber].stop(); // shouldn't crash the sketch, but it does | |
videos[eventnumber].play(); | |
//events = pop(events)// take the first item out of an array | |
} | |
}else{ | |
videoIsPlaying = true; | |
} | |
} | |
void keyPressed(){ | |
//println(key); | |
if (key == '1'){ | |
eventnumber = 1; | |
videos[eventnumber].stop(); | |
videos[eventnumber].play(); | |
} | |
if(key == '2'){ | |
eventnumber = 2; | |
videos[eventnumber].stop(); | |
videos[eventnumber].play(); | |
} | |
if(key == '3'){ | |
events = append(events, 1); | |
println(events); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment