Recitation 10: Workshops by Xueping

Slide:

https://docs.google.com/presentation/d/1caNLRobmOTDkGvQKPCULgM2MbfE6JPNQP8-Zk-_fBnk/edit#slide=id.g5705e94f86_0_4

import processing.video.*;
Movie myMovie;
int previousX = 0;
int distance;

void setup() {
  background(0);
  size(640, 480);
  myMovie = new Movie(this, "music.mp4");
  myMovie.loop();
}
void movieEvent(Movie movie) {
  myMovie.read();  
}
void draw() { 
  if (myMovie.available()) {
//read my file when it can be read
    myMovie.read();
//read the current frame of the video
  }
  image(myMovie, 0, 0);   
  distance = mouseX - previousX;
  float newSpeed = map(distance, -width, width, 0.1, 5);
  myMovie.speed(newSpeed);
  previousX = mouseX;
}  

Leave a Reply