We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hey guys! I'm just beginning with Processing, so this is probably something just easy that I still don't understand. Okay now the project: I am trying to make this player that randomize some videos to display them in three different mask (together they form a entire screen) with three different keyboard keys... The masks and, theoretically the random aspect are done, but I really can't figure out how to activate the masks with the keys without using the same array output (without using the same random picked video in all three masks)...And it really sounds complicated, but if someone could help me I would be eternally grateful. (Windows 7/ Processing 2.2.1)
import processing.video.*;
import ddf.minim.*;
//Audio
AudioPlayer player;
Minim minim;//audio context
//
PImage mask1;
PImage mask2;
PImage mask3;
//Array-random
int maxMovies= 4;
int rand = int(random(maxMovies));
Movie[] myMovies=new Movie[maxMovies];
ArrayList<Movie> moviesPlaying = new ArrayList<Movie>();
void setup() {
size (640, 480, P3D);
frameRate(30);
//sound
minim = new Minim(this);
player = minim.loadFile("cocoon.mp3", 2048);
player.play();
//masks
mask1 = loadImage("center.jpg");
mask2 = loadImage("left.jpg");
mask3 = loadImage("right.jpg");
for (int i = 0; i < myMovies.length; i ++ ) {
myMovies[i] = new Movie(this, i+".mov");
}
}
void keyPressed() {
if (key=='a') {
rand = int(random(maxMovies));
moviesPlaying.add(myMovies[rand]);
moviesPlaying.get(moviesPlaying.size()-1).loop();
}
}
void draw() {
background(0);
for (int i = 0; i< moviesPlaying.size (); i++ ) {
Movie m = moviesPlaying.get(i);
if (m.available())
m.read();
m.mask(mask1);
image(m, 0, 0);
}
}
void stop()
{
player.close();
minim.stop();
super.stop();
}
Answers
I can't grasp exactly what you're trying to achieve, sorry.
For now I did the example below just to test waters out.
Check it out for yourself whether it gets close to what you wish:
Wow, thank you so much for your help @GotoLoop, and yeah I probably made it look more complicated than it is. Unfortunately this don't help me. I have three masks, so every time I press a keyboard button its randomically plays a video from my array (oh but I need it to be 3 different buttons). I am trying to rewrite the code with little success, so any help is really welcomed.
Again not well explained... At least I can't get it yet: 8-|
You see by now that lotsa information is missing.
You need to lay out exactly what's your program is about to do. :-B
Sorry...I will try to explain it: 1.Yup, playing at same time. 2.Same coordinates, always centered. 3.The masks are constant, only the videos from an array that are applied in it randomly. 4.Okay, every time I press one button it activates a mask, and the video inside it. There is a video playing in the background, if you press "a", it activate a new layer over the video, for example.
Thank you so much by your time, and sorry again T.T...
There are some contradictions here:
And most importantly, what is exactly the bug from your sketch?
Does it compile, or throws an exception or simply doesn't have the desired result? :-B
Did my own version run there anyways? :-/
Thank you again. In my code the masks are working okay, the main problem is that I don't know how to pick a random movie from my array every time I press a different button and put it in a mask. It's works, but with just one key, if I try to add another key, well I don't know how to put another one... About the masks: 3 masks complete the entire screen, each mask pick a random video from my array every time a key is pressed. The video I talked about (in the bg) don't have a mask, is not even in the array. I just call to play so if anyone play any button the screen won't be black.
My big problem is in this part:
How can I add more key (buttons) and make it activate the other masks like this?
Hey! @GoToLoop I am back. And I did it, well sorta of... My code works but only without the masks, when I activate the masks I got this error: "mask() can only be used with an image that's the same size" but the weird thing is that I made I code testing the masks and it works! Every time I put the array aspect of the code, its gimme this kind of error. It's bizarre. Oh, and sorry but I couldn't use your code 'cause I really can't understand most of it, so I just did it and learned a lot! Anyway thank you by your time :)