Jumping to a specific frame
In the previous recipe, you learned how to control the speed of your movie. In this one, we'll take a look at how you can jump to a specific position inside the video file.
How to do it...
We'll start with the same code as in the first recipe, but we'll add a float
variable named w
, which we will use to draw a progress bar to the screen.
import processing.video.*; Movie m; float w; void setup() { size( 640, 480 ); m = new Movie( this, "marbles.mov" ); m.loop(); } void draw() { background( 0 ); image( m, 0, 0, width, height ); fill( 0 ); noStroke(); rect( 0, 0, w, 10 ); }
The movieEvent()
function looks a little different. We'll map the current time of the movie to a value between 0
and the width
of our sketch window and store it in the w
variable.
void movieEvent( Movie m ) { m.read(); w = map( m.time(), 0, m.duration(), 0, width ); }
In the mousePressed()
function, we'll map the value of the mouseX
variable to a range between 0
and...