14.2 – Libraries: Sound & Video

Whenever we call a Processing function, such as line( ), background( ), stroke( ), and so on, we are calling a function that we learned about from the Processing reference page. That reference page is a list of all the available functions in the core Processing library.  A library is like “helper” code.

You can use additional libraires that are not included in the core Processing library. Processing comes with a few built in, extra libraries. They are not available to you until you import that library into your sketch, with the line of code:

import libraryname.*;

Better yet, go to SKETCH –> IMPORT LIBRARY to both see a list of available libraries and to add the appropriate line of code to your sketch

The built-in libraries don’t require any installation to your computer. But! You are not limited to these libraries. You can install 3rd party libraries to help you with anything from extensive sound manipulation to computer vision to physics rendering. Libraries are collections of functions and objects that do the heavy lifting for us for complex tasks.

One of the built-in libraries is Processing’s video library. You can use this library to play a video or sound.

An example of video playback:

import processing.video.*; //This is your first import statement

Movie movie; // Make a movie object for your sound file

void setup() {
size(200, 200);
movie = new Movie (this, "dingdong.wav"); //initialize your sound file

void draw() {

void mousePressed() {
movie.stop(); //stop the sound file
movie.play(); //play the sound file

And an example of playing a video:

import processing.video.*;
Movie movie; //make a new movie object

void setup(){
 movie = new Movie(this, "zombie.mov");  //initialize the movie object
 size( 720, 304 );
 movie.loop(); //either play() or loop() the video

void draw(){
  movie.read(); //go get a few frame from the movie
  image(movie, 0, 0); //display the movie

Leave a Reply

Your email address will not be published.