/** * Frames. * by Andres Colubri * * Moves through the video one frame at the time by using the * arrow keys. */ import codeanticode.gsvideo.*; GSMovie myMovie; int newFrame = 0; PFont font; void setup() { size(320, 240); background(0); // Load and set the video to play. Setting the video // in play mode is needed so at least one frame is read // and we can get duration, size and other information from // the video stream. // myMovie = new GSMovie(this, "/Volumes/Reservoir/Assets/Video/abby at computer"); myMovie = new GSMovie(this, "/Volumes/Reservoir/Assets/Video/reading from script"); myMovie.play(); font = loadFont("GillSans-24.vlw"); textFont(font, 24); } void movieEvent(GSMovie myMovie) { myMovie.read(); } void draw() { if (1 < myMovie.width && 1 < myMovie.height) { if (newFrame != myMovie.frame()) { // The movie stream must be in play mode in order to jump to another // position along the stream. Otherwise it won't work. myMovie.play(); myMovie.jump(newFrame); myMovie.pause(); } image(myMovie, 0, 0, width, height); fill(240, 20, 30); text(myMovie.frame() + " / " + (myMovie.length() - 1), 10, 30); } } void keyPressed() { if (key == CODED) { if (keyCode == LEFT) { if (0 < newFrame) newFrame--; } else if (keyCode == RIGHT) { if (newFrame < myMovie.length() - 1) newFrame++; } } }