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
Video *play* and *stop* control (Read 794 times)
Video *play* and *stop* control
Nov 30th, 2009, 2:08pm
 
Hiya

Am aiming to permit play and stop of video from human interaction.

Have been playing with this code and reached point of video playing looped until key depressed. Video just stays at same frame. I'm aiming to: keypress & play video until finish otherwise if keyreleased then reset video..

Where am I going wrong, any ideas?

Thanks

Code:
import processing.video.*;

int i=0;
Movie theMov;
boolean isPlaying;
boolean isLooping;

void setup() {
size(640, 480);
background(0,0,0);
theMov = new Movie(this, "2.mp4");
theMov.play(); // tried loop, just plays movie again and again
//isPlaying = true;
//isLooping = true;
}

void draw() {
if (keyPressed == true) {
i++;
fill(0,0,0,i); //i is used for transperancy
rect(0,0,width,height);
//the 60 stands for 4 seconds seeing as its 4x15
if (i > 60) {
i = 0;
}
image(theMov, 0, 0);
}
else if (keyPressed == false) {
theMov.stop();
i++;
fill(255,255,255,i); //i is used for transperancy
rect(0,0,width,height);
//the 60 stands for 4 seconds seeing as its 4x15
if (i > 60) {
i = 0;
}

}
}

void movieEvent(Movie m) {
m.read();
}
Re: Video *play* and *stop* control
Reply #1 - Nov 30th, 2009, 2:17pm
 
thankfully some tinkering sorted it.

now solved!
Re: Video *play* and *stop* control
Reply #2 - Nov 30th, 2009, 2:18pm
 
Code:
	else if (keyPressed == false) {
// theMov.stop();
i++;
fill(255,255,255,i); //i is used for transperancy
rect(0,0,width,height);
//the 60 stands for 4 seconds seeing as its 4x15
if (i > 60) {
i = 0;
}
[b] theMov.loop();[/b]
}


solved it
Page Index Toggle Pages: 1