how to load movie file paths into array

edited June 2014 in How To...

how do i load movie file paths into array so i don't need to specify them for each movie instance?

this is how i would do this for image files:

PImage[] p = new PImage[20];

for (int i = 0; i < p.length; i++) {
    p[i] = loadImage("v"+nf(i, 2) + ".jpg"); 
  }

but what to use for movie files?

Tagged:

Answers

    • Your example isn't storing paths, but actual PImage instances.
    • In the Processing's IDE, hit CTRL+SHIFT+O in order to open examples
    • Click on: Libraries -> video -> Movies.
    • You'll find many examples there!
  • that's the problem,i wanted to know how to store paths! in Libraries -> video -> Movies all examples use single video file

    like: String PATH= "/home/video01.mp4"; Movie mov; mov =new Movie(this,PATH);

    how do i scan some folder with few video files and then store in array to use PATH[0], PATH[1] etc.

  • Arrays use the same [] syntax. As you did for PImage: PImage[] imgs = new PImage[20];,
    do the same for Movie: Movie[] movs = new Movie[5].

    For paths you can use String[]: String[] paths = new String[movs.length];

    And for more advanced tips, go here:
    http://forum.processing.org/two/discussion/2578/how-to-filter-and-order-a-set-of-files

  • //ok, make array, easy
        Movie[] movs = new Movie[5]
         String[] paths = new String[movs.length];
    
      //but confused about this 
        for (int i = 0; i < movs.length; i++) {
    //how to load files i got in my data folder or somewhere else?
            paths[i] = ???
          }
    
  • edited June 2014
    // forum.processing.org/two/discussion/6037/
    // how-to-load-movie-file-paths-into-array
    
    import processing.video.*;
    
    static final String FILE = "video", EXT = ".mp4";
    static final int NUM = 5;
    
    final String[] paths = new String[NUM];
    Movie mov;
    int idx;
    
    void setup() {
      size(800, 600, JAVA2D);
    
      String folder = dataPath("") + "/";
      println(folder);
      println();
    
      for (int i = 0; i != NUM; println(paths[i++] =
        folder + FILE + nf(i, 2) + EXT));
    
      exit();
    }
    
  • hi, thank you, for some reason i got "could not load movie file message" where's my mistake?

    import processing.video.*;
    
    static final String FILE = "video", EXT = ".mp4";
    static final int NUM = 5;
    
    final String[] paths = new String[NUM];
    Movie mov;
    
    void setup(){
    
      size(320, 240,JAVA2D);
      String folder = dataPath("") + "/";
      println(folder);
      println();
    
      for (int i = 0; i != NUM; println(paths[i++] =
        folder + FILE + nf(i, 2) + EXT));
    
      exit();
      mov =new Movie(this,paths[0]);
      mov.loop();
    
    }
    
    void movieEvent(Movie m){
      m.read();
    
    }
    
    void draw(){
      background(255);
      image(mov, 0, 0, width, height);
    
    }
    
  • Already answered in how to make a movie array?
    Making several similar topics isn't good as it dilutes information and efforts of those wanting to help...

Sign In or Register to comment.