Recitation 9: Media Controller – by Anica Yao

In this project, I connected the button/switch with a video about subway. You long press the button to play the video, otherwise the video will pause. There are three points that I need to pay attention to:
(1) Before I play the video, I need to define the movie and upload the file first. If necessary, draw the frame. 
(2) I couldn’t play the first frame at first ( the screen is all black ), and thanks to Jintian’s help, I learned that I need to draw the first frame in the setup().
(3) The video couldn’t play smoothly. After I change the value of delay() it went better. 
In the article ” Computer Vision for Artist and Designers”, I learned that computer vision is important in not only physical world but multimedia authoring tools. When I was doing my project, I simply used single variable from Arduino to processing to control the video to be played or paused. But by using multivariable serial communication it’s possible to use physical components to adjust both visual and audio things (e.g. the tent, the speed, the frequency and the volume of the sound, etc. ) Besides, the video pixel capture might also be a worthy method to start with. In my opinion, processing is more a bridge than a destination. It should process the physical information from the video, and create the computer vision beyond the original content of the video, which contains more art and interaction experience.

Processing Codes: 

// IMA NYU Shanghai
// Interaction Lab
// This code receives one value from Arduino to Processing 

import processing.serial.*;
import processing.video.*;
Movie myMovie;

Serial myPort;
int valueFromArduino;


void setup() {
  size(1000, 600);
  myMovie = new Movie(this, "Pexels.mov");
  //myMovie.play();

 if (myMovie.available()) {
    myMovie.read();
  } // read the file
  myMovie.play(); //play the video
  image(myMovie, 0, 0, width, height); //draw the frame

  printArray(Serial.list());
  // this prints out the list of all available serial ports on your computer.

  myPort = new Serial(this, Serial.list()[ 7 ], 9600);
  // WARNING!
  // You will definitely get an error here.
  // Change the PORT_INDEX to 0 and try running it again.
  // And then, check the list of the ports,
  // find the port "/dev/cu.usbmodem----" or "/dev/tty.usbmodem----" 
  // and replace PORT_INDEX above with the index number of the port.
}


void draw() {
  // to read the value from the Arduino
  while ( myPort.available() > 0) {
    valueFromArduino = myPort.read();
  }
  println(valueFromArduino);//This prints out the values from Arduino
  background(valueFromArduino); // only reads 0-255. if over range it reset to 0 again

  if (myMovie.available()) {
    myMovie.read();
  }
  if (valueFromArduino ==1) {
    myMovie.play();
  } else {
    myMovie.pause();
  }
    image(myMovie, 0, 0, width, height); //draw the frame
}

Notes:
Video by Danilo Obradović from Pexels

Leave a Reply