Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : quick! help setting up a video array?

$
0
0
I got 20 movies running with this code below (2.0b8). Sometimes it hangs while adding  anew movie though...

  1. import processing.video.*;

  2. int maxMovies= 42;
  3. int rand = int(random(maxMovies)); 

  4. Movie[] myMovies=new Movie[maxMovies] ;

  5. ArrayList<PVector> moviePos      = new ArrayList<PVector>();
  6. ArrayList<Movie>   moviesPlaying = new ArrayList<Movie>();

  7. Movie firstClipMovie;


  8. void setup() {
  9.    size (1100, 600);

  10.   for (int i = 0; i < myMovies.length; i ++ ) {
  11.     myMovies[i] = new Movie(this, "25.mov");
  12.   }

  13.   firstClipMovie = new Movie(this, "tet.mov");
  14.   firstClipMovie.loop();

  15.   moviesPlaying.add(firstClipMovie);
  16.   moviePos. add(new PVector (0, 0));

  17.   background(0);
  18. }



  19. void mouseReleased() {
  20.   rand = int(random(maxMovies));

  21.   //store position
  22.   moviePos.add(new PVector(mouseX, mouseY));

  23.   // loop movie and add to playing list 
  24.   moviesPlaying.add(myMovies[rand]);
  25.   moviesPlaying.get(moviesPlaying.size()-1).loop();
  26. }

  27. void draw() {
  28.   background(0);
  29.   tint(255, 155);

  30.   for (int i = 0; i< moviesPlaying.size(); i++ ) {    
  31.     // temp vars to keep things neat :)
  32.     Movie m = moviesPlaying.get(i);
  33.     float x = moviePos.get(i).x;
  34.     float y = moviePos.get(i).y;

  35.     
  36.     if (m.available())
  37.       m.read();

  38.     image(m, x, y);
  39.   }
  40.   
  41.   //frameRate
  42.  
  43.   frame.setTitle("fps" + frameRate);
  44. }


Viewing all articles
Browse latest Browse all 1768

Trending Articles