Skip to content

Instantly share code, notes, and snippets.

@phraemer
Last active December 26, 2015 01:09
Show Gist options
  • Save phraemer/7069583 to your computer and use it in GitHub Desktop.
Save phraemer/7069583 to your computer and use it in GitHub Desktop.
import processing.video.*;
import java.util.*;
class Visual {
public String m_file;
public boolean m_image;
public Visual( String file, boolean image ) {
m_file = file;
m_image = image;
}
};
Visual[][] g_visuals = {
{
new Visual("transit.mov", false),
new Visual("liam.mov", false),
new Visual("tricover.png", true)
}
,
{
new Visual("test2e_2.mov", false),
new Visual("rrrrrrrrr.mov", false),
new Visual("fancy.jpg", true)
}
};
ArrayList<Movie> g_movies = new ArrayList<Movie>();
ArrayList<PImage> g_images = new ArrayList<PImage>();
int g_drawMovie = 0;
int g_drawImage = -1;
void setup() {
//size(640, 360);
size(displayWidth, displayHeight, P3D);
background(0);
// Load and play the video in a loop
for (Visual[] va:g_visuals) {
for (Visual v:va) {
if (v.m_image) {
g_images.add(loadImage(v.m_file));
}
else {
Movie movie = new Movie(this, v.m_file);
movie.loop();
g_movies.add(movie);
}
}
}
}
boolean sketchFullScreen() {
return true;
}
void movieEvent(Movie m) {
m.read();
}
void draw() {
//if (movie.available() == true) {
// movie.read();
//}
if (g_drawMovie >= 0 )
{
image(g_movies.get(g_drawMovie), 0, 0, width, height);
}
if (g_drawImage >= 0 ) {
image(g_images.get(g_drawImage), 0, 0, width, height);
}
}
void keyPressed() {
int newMovie = g_drawMovie;
int newImage = g_drawImage;
if (key == 'a') {
newMovie = 0;
}
else if (key == 's') {
newMovie = 1;
}
else if (key == 'd') {
newMovie = 2;
}
else if (key == 'f') {
newMovie = 3;
}
else if (key == 'h') {
newImage = 0;
}
else if (key == 'j') {
newImage = 1;
}
// Turn off images
else if (key == ' ') {
newImage = -1;
}
if (newMovie < g_movies.size()) {
g_drawMovie = newMovie;
}
if (newImage < g_images.size()) {
g_drawImage = newImage;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment