We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
function loop?? (Read 244 times)
function loop??
Mar 18th, 2009, 10:10am
 
Hello!

I'm new in Processing and I'm trying to make something.

I've a little program to change around 4 videos by keys.

If you pressed key '1' you play video1, for key '2' video2, etc..

But the problem is that the read of the code is lineal, so you can change from 1 to 2 and later to 3 and later to 4 but you can come back to some video down.

Can you understand me?

I think the problem is that when you read a video is there (in the "draw") so when you "call" to another video down you can't see it because is down.

I would like to know if is possible to work with layers or something similar to say which video must be visible, or something like "unread" the videos...

Can you help me?
Thank you very much! Smiley
Re: function loop??
Reply #1 - Mar 18th, 2009, 10:37am
 
I'm not quite sure what approach you're doing but I think you'll want something like:

Code:

//assuming you have objects for each video in variables video1 video2 etc...

int play=1;

void setup()
{
//load your videos.
video1.play();
}

void draw()
{
background(0);
if(play==1)
image(video1,0,0);
if(play==2)
image(video2,0,0);
//etc
}

void keyPressed()
{
if(key=='1' && play!=1)
{
play=1;
video1.play();
video2.pause();
video3.pause();
video4.pause();
}
if(key=='2' && play!=2)
{
play=2;
video1.pause();
video2.play();
//etc etc
}
//etc etc
}

}
}
Re: function loop??
Reply #2 - Mar 18th, 2009, 11:41am
 
Thank you very much John!

This is exactly that I was trying to do!

And it works perfectly!

Thank you again Smiley
Page Index Toggle Pages: 1