User Tools

Site Tools


cs276:ex16-6

Note: default video library does not work in Linux.

// Learning Processing
// Daniel Shiffman
// http://www.learningprocessing.com
 
// Example 16-5: Scrubbing forward and backward in movie
 
// If mouseX is 0, go to beginning
// If mouseX is width, go to end
// And everything else scrub in between
 
import processing.video.*;
 
Movie movie;
 
void setup() {
  size(320,240);
  movie = new Movie(this, "cat.mov");
}
 
void draw() {
 
  // Ratio of mouse X over width
  float ratio = mouseX / (float) width;
 
  // The jump() function allows you to jump immediately to a point of time within the video. 
  // duration() returns the total length of the movie in seconds.  
  movie.jump(ratio*movie.duration()); 
 
  // Read frame
  movie.read(); 
  // Display frame
  image(movie,0,0); 
}
cs276/ex16-6.txt · Last modified: 2009/11/10 09:41 by scarl