Recitation 10: Media Manipulation Workshop by Jiahui Zhang

For this recitation, I choose the media manipulation workshop and learn how to map and change the video based on the Arduino input. There are more interesting functions of the movie such as “myMovie.jump”, “myMovie.time()”. I use the potentiometer to control how long the video goes forward or going backward based on the X position the mouse pressing. Originally, I want to use the map function inside of the processing in order to jump to a specific time of the film based on the pixel my mouse pressed. However, it is hard to achieve so that I just send the value from the Arduino to the Processing and mapping the value from the Arduino with the length (second) of the film I have.

References (The video used):

https://www.youtube.com/watch?v=xQ5314dTOBI

The code for the Arduino is just as the example given before. (One value from A to P).

The code for the Processing is as follows:

import processing.video.*;
Movie myMovie;
import processing.serial.*;
Serial myPort;
int valueFromArduino;

void setup() {
  size(640, 360);
  myMovie = new Movie(this, "The Forest || Cinematic.mp4");
  myMovie.play();
   printArray(Serial.list());
  // this prints out the list of all available serial ports on your computer.

  myPort = new Serial(this, Serial.list()[ 2 ], 9600);
  //define the state of the video
}
void draw() {
  while ( myPort.available() > 0) {
    valueFromArduino = myPort.read();
  }
  println(valueFromArduino);
  float x = map(valueFromArduino,0,1023,0,93);
  if (myMovie.available()) {
    //read my file when it can be read
    myMovie.read();
    //read the current frame of the video
  }
  //draw the frame
  if (mousePressed){
   if (mouseX<width/2){
     myMovie.jump(myMovie.time()-x);
     myMovie.read();
   }else{
     myMovie.jump(myMovie.time()+x);
     myMovie.read();
   }
  }
  image(myMovie, 0, 0);
}

Leave a Reply