/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

	This file is part of "Interface Fractures III - Silicon".
	Copyright (c) 2015 Luka Prinčič, All rights reserved.
	This program is free software distributed under
	GNU General Public Licence. See COPYING for more info.
	- - - - - - - - - - - - - - - - - - - - - - - - - - - -

  getVideos.pde
                                                                             */

Movie[][] getVideos(String folder) {

  Movie[][] vidPool;

  
  File dir = new File(dataPath(sketchPath() + folder)); // first folder
  String[] dirlist = dir.list(); // an array of folders (strings)
  dirlist = sort(dirlist); //

  //println("... dirlist array:");
  //  printArray(dirlist);
  //println("    from: "  + dir);

  //vidPool = new ArrayList<ArrayList>();

  vidPool = new Movie[dirlist.length][100]; // create 2d array imgPool

  for (int i = 0; i < dirlist.length; i++) {
    //println("here" + dirlist);
    String fulldir = dataPath(sketchPath() + folder + dirlist[i]) + "/";
    File dir2 = new File(fulldir);
    String[] filelist = dir2.list(); // an array of image names
    filelist = sort(filelist);
    println("\n~~~ VIDEO BANK no." + i + ": " + dirlist[i]);
    
    if (filelist.length != 0) {
      vidPool[i] = (Movie[]) expand(vidPool[i], filelist.length);
      //     geez: ^^^^^^^^^^ !!!!!

      for (int j = 0; j < filelist.length; j++) {
        println("___ vidPool[" + i + "][" + j + "]: " + dirlist[i] + " " + filelist[j]);
        vidPool[i][j] = new Movie(this, fulldir + filelist[j]);
        
        delay(40);
      }
      println("");
      delay(400);
      
    } else {
      println("No files in this folder: " + fulldir);
    }    
  }

  println("\n~~~ Done loading videos.\n");

  return vidPool;
  

/* // in setup:

video = new GLMovie(this, "stuffloor2.mov");
video.loop();

*/


}
