For this week’s recitation class, we were tasked with creating a “knock-off” music video using images and videos, so I decided to create Rebecca Black’s “Friday” music video! First, I uploaded an image of a few girls riding around in a car. In order to do this, I used the variable “PImage” and put the photo code into void setup because I wanted the image to play one time. Next, I downloaded a video from the internet of a girl riding around in a car. In order to put this in processing, I imported the movie from my library and then put the movie processing code into void draw to to play the video. Then, since I wanted to play the image and then the video, I put in this code “if (millis()/1000 > 5)” which allowed me to telling processing that after 5 seconds, I wanted the image to end and start the video. Lastly, I talked to Marcela and she helped me insert music as well. I downloaded a simple sound code, and then downloaded the “Friday” song. I used boolean so that when the song plays, it will not be affected by the image and video changing as well; At first, when we didn’t have boolean, the song would repeat itself after 5 seconds because of the “millis” or time code.
import processing.video.*; import processing.sound.*; Movie myMovie; SoundFile soundfile; PImage photo; boolean isPlaying=false;//this helps us so that the song won't restart with the millis starting over void setup () { size (550, 380); background(255); photo = loadImage ("download.jpg"); //Rebecca Black - Friday.mp3 image (photo, 100, 100); myMovie = new Movie (this, "friday.mp4"); soundfile = new SoundFile(this, "Friday3.mp3"); } void draw () { if (myMovie.available ()) { myMovie.read (); } if (millis()/1000 > 5) { //println(millis()/1000); background(255); myMovie.loop(); myMovie.volume(0); image (myMovie, 0, 0); if (isPlaying == false) { playSong();//if it's not playing, then it'll play } } } void playSong() { isPlaying=true; //this will make it play through one time soundfile.play(); }
VIDEO:IMG_0299 2