jit.qt.movie --> videoplane --> window in JS problems


    Mar 05 2013 | 2:57 am
    Greetings, hive mind,
    I'm attempting to write a moviebank type thing in js, based on the moviebank example, with two main differences:
    1. the movies all play simultaneously (not the biggest deal, I think) 2. each movie has its own videoplane, and those are offset relative to each other in a window
    I'm not getting the planes to show up, although as far as I can tell, movies are successfully loading into the jit.qt.movie objects, and nothing seems out of order with instantiating my videoplanes. I suspect I'm doing something wrong in the bang() function, but my researches so far have yet to provide me with an answer. I'd appreciate it if someone could have a look for me...
    Thanks!
    JS: (moviebank.js)
    //moviebank.js
    autowatch = 1;
    outlets = 3;
    var window = new JitterObject("jit.window","window"); window.size = [1280, 320];
    var render = new JitterObject("jit.gl.render","window");
    var vdim = [320,240]; var vindex = 0; var vcount = 0; var movArray = new Array(); //jit.qt.movie objects var outMatrix = new Array(); // intermediate matrices -- I don't even know if I need these... var planeArray = new Array(); //videoplanes var dummymatrix = new JitterMatrix(4,"char",vdim[0],vdim[1]); var filenames = new Array();
    // I think my error is in here -- in theory, I'm passing the movies to the matrices, and then using the matrix name to assign it to the videoplane
    function bang() {
    render.erase(); for(var i = 0; i movArray[i].matrixcalc(outMatrix[i]/*null*/,outMatrix[i]); planeArray[i].jit_matrix(outMatrix[i].name); planeArray[i].draw(); } render.drawswap(); }
    /* function index(i) { if (i>=vcount) i = vcount-1; if (i i = 0;
    movArray[vindex].stop(); vindex = i; movArray[vindex].start(); } */
    function readfolder(foldername) { var fold; var i,rv;
    fold = new Folder(foldername); fold.typelist = ["MooV","PICT","MPEG","GIFf","JPEG","PNG","TIFF","SWFL","8BPS","BMP","VfW"] if (fold.count) { // reset old movies for (i=0;i movArray[i].dispose(); movArray[i].matrixcalc(dummymatrix/*null*/,dummymatrix); } // build filename array vcount = 0; fold.reset(); filenames = new Array(); outlet(1,"clear"); //clears menu, which we probably don't need // load new movies for (i=0;i fold.next(); filenames[vcount] = fold.pathname + "/" + fold.filename; movArray[vcount] = new JitterObject("jit.qt.movie"); // add movie attributes here movArray[vcount].vol = 0; movArray[vcount].colormode = "uyvy"; movArray[vcount].unique = 1;
    rv = movArray[vcount].read(filenames[vcount]); if (rv[1]==1) { // success, read returns an array [filename,success]
    // create intermediate matrices and videoplanes
    outMatrix[vcount] = new JitterMatrix(4,"char",vdim[0],vdim[1]); planeArray[vcount] = new JitterObject("jit.gl.videoplane", "render"); // add plane attributes here planeArray[vcount].transform_reset = 2; planeArray[vcount].colormode = "uyvy"; planeArray[vcount].automatic = 0; planeArray[vcount].rotatexyz[0,0,90]; planeArray[vcount].scale[0.2,0.2,1]; planeArray[vcount].color[1,1,1,1];
    //position planes here -- this is sloppy, but not the problem...
    var max = -6; var offset = .4; var pos = (max+ (vcount * offset)); planeArray[vcount].postion = [pos, 0., 0.]; post("nposition " , pos, "vcount " , vcount);
    outlet(1,"append",fold.filename); movArray[vcount].loadram; movArray[vcount].matrixcalc(outMatrix[vcount]/*null*/,outMatrix[vcount]); vcount++; } } if (vindex>=vcount) vindex = 0; // movArray[vindex].matrixcalc(outMatrix[vindex]/*null*/,outMatrix[vindex]); outlet(2,vcount); } }
    function dim(width,height) { vdim[0] = width; vdim[1] = height; for (i=0;i outMatrix[i].dim = vdim; } dummymatrix.dim = vdim; }
    /* function anything() { //pass off all other messages to the movie object var a = arrayfromargs(arguments); if (Function.prototype.isPrototypeOf(movArray[vindex][messagename])) { movArray[vindex][messagename](a); } else { movArray[vindex][messagename] = a; } }
    */
    Patcher:

    • Mar 05 2013 | 11:37 am
      Hi Matthew,
      Your render and window are named "window" (I would choose a different name to avoid potential collisions, but that's just me), but your videoplanes are named "render". I haven"t tested your JS with that fix, but it seems like the most likely culprit on a quick scan.
      Jeremy
    • Mar 05 2013 | 1:40 pm
      Jeremy!
      I'm too stupid to live, obviously. This is why I never get called back for those jobs at Google. I had the same problem in high-school math -- I understood the logic, but let the details slip through....
      Thanks, Jeremy.
      M