import processing.video.*; MovieMaker mm; // declare moviemaker object Movie mov; // declare movie object int rad = 50; // circle's diameter int fps = 15; // frames per second int func = 0; // function: rec = 1, play = 2, pause = 3, stopRec = 4 boolean drawE = true; void setup() { // set size size(500,300,P2D); // set background color background(255); // set mouse cursor type cursor(HAND); } void draw() { // draw ellipses randomly if (drawE == true) { noStroke(); ellipse(random(0,600),random(0,400), rad, rad); fill(random(0,255),random(0,255),random(0,255),mouseY); } // add actual window's pixels to movie if (func == 1) mm.addFrame(); // play movie if (func == 2) { background(255); image(mov, 0, 0); } } void keyPressed() { // stop recording if (key == 's') { func = 4; mm.finish(); } // record animation if (key == 'r') { drawE = true; func = 1; // Create movie object with size, filename, compression codec and quality, framerate mm = new MovieMaker(this,width,height,"aufgabe3.mov",fps,MovieMaker.H263, MovieMaker.HIGH); } // play/pause recorded video if (key == 'p') { if (func!=2 && func!=3) { System.out.println("P / not 3 not 2 / play / func=" + func); func = 2; mov = new Movie(this, "aufgabe3.mov"); mov.play(); mov.loop(); } else if (func == 3) { System.out.println("P / 3 / play / func=" + func); drawE = false; func = 2; mov.play(); mov.loop(); } else { drawE = false; func = 3; System.out.println("P / 2 / pause / func=" + func); mov.pause(); } } // redraw confettis if (key == 'd') { func = 0; drawE = true; background(255); } } // Called every time a new frame is available to read void movieEvent(Movie m) { m.read(); }