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.
IndexProgramming Questions & HelpVideo Capture,  Movie Playback,  Vision Libraries › playing a random sequence of videos from a string
Page Index Toggle Pages: 1
playing a random sequence of videos from a string (Read 653 times)
playing a random sequence of videos from a string
Nov 20th, 2007, 4:24am
 
I am trying to play a randomly selected sequence from a string but theres a weird bug. After the first clip is done, it loads the audio from the second clip but the image stalls on the last frame of the first clip. If anyone has any advise I would probably love you forever.

import processing.video.*;

String[] one = {"1.mov","2.mov","3.mov"};

Movie myMovie;

int a = 0;        
float md = 0;
float mt = 0;

void setup() {
size(200, 200);
 background(0);
 myMovie = new Movie(this, one[int(random(one.length))]);
 println(myMovie.duration());
 myMovie.play();

}


void draw() {
 if(a == 0) {
   image(myMovie, 0, 0);
 }
 image(myMovie, 0, 0);

 float md = myMovie.duration();
 float mt = myMovie.time();
 println(md - mt);
 if (md - mt<0.1){// to find the end of the movie
 myMovie = new Movie(this, one[int(random(one.length))]);
 }
}

void movieEvent(Movie m) {
m.read();
}
 
Re: playing a random sequence of videos from a str
Reply #1 - Jan 24th, 2008, 2:25pm
 
Not tested, but you should try this:

 if (md - mt<0.1){// to find the end of the movie
   myMovie = null;
   myMovie = new Movie(this, one[int(random(one.length))]);
   myMovie.play();
 }
Page Index Toggle Pages: 1