[javascript-dev] Re: JitterListener and jit.qt.movie read...bug?
pnyboer
pnyboer at slambassador.com
Mon Jul 9 22:02:14 MDT 2007
- Previous message: [javascript-dev] Re: JitterListener and jit.qt.movie read...bug?
- Next message: [javascript-dev] Re: JitterListener and jit.qt.movie read...bug?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Can you stand another one? I hope so, cuz I seem to surfing the edges of Max scheduling, and not understanding it.
This simple, but complete, patch and javascript are an attempt to read a folder of movies and output a sample frame from each, using a Task and JitterListener. The big mystery to me is why when I use the mov.matrixcalc() method in function thecallback(), it doesn't actually output a matrix. The simple example of "readit", when called from the outside does what I want to do, so I know I'm using the correct code to output a matrix from a jit.qt.movie in js. I presume it has to do with the asyncread, which the JitterListener seems to say is all finished, but it is apparently not, since the matrixcalc results in nothing!
Is there a way to get this working??
Thanks,
Peter.
#P window setfont "Sans Serif" 9.;
#P window linecount 3;
#P comment 394 301 127 196617 for the sake of testing \, store up to 72 images for easy recall;
#P window linecount 4;
#P comment 389 86 127 196617 read \, rather than asyncread each movie in the folder \, and a frame is output after each read;
#P window linecount 1;
#P message 21 151 22 196617 set;
#P window linecount 4;
#P comment 141 94 139 196617 should output the 30th frame from each movie read....but it doesn't \, i guess becuase of the "asyncread";
#P comment 324 47 48 196617 bang out the last movie's matrix;
#P window linecount 1;
#P comment 185 254 38 196617 count:;
#P number 218 253 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 185 235 35 196617 total:;
#P number 218 234 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 422 230 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 422 254 82 196617 outputmatrix \$1;
#P newex 343 253 72 196617 prepend index;
#P user jit.pwindow 310 306 82 62 0 1 0 0 1 0;
#P newex 311 231 27 196617 t l b;
#N counter;
#X flags 0 0;
#P newobj 343 231 66 196617 counter;
#P newex 371 210 21 196617 t 0;
#P newex 311 281 158 196617 jit.matrixset 72 4 char 320 240;
#P button 131 232 15 0;
#P number 381 46 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 381 68 52 196617 readit \$1;
#P button 309 46 15 0;
#P newex 45 129 62 196617 prepend set;
#P window linecount 0;
#P message 45 150 244 196617;
#P user jit.pwindow 46 232 82 62 0 1 0 0 1 0;
#P window linecount 1;
#P newex 131 173 91 196617 prepend drawtiles;
#P newex 131 206 115 196617 js draw_tiles_async.js;
#P comment 149 55 127 196617 drag a folder of clips here;
#P user dropfile 131 36 298 90 1;
#P fasten 18 0 17 0 427 249 427 249;
#P connect 9 0 8 0;
#P connect 12 0 13 2;
#P connect 3 0 2 0;
#P fasten 3 0 12 0 136 200 376 200;
#P connect 13 0 16 0;
#P connect 14 1 13 0;
#P connect 11 0 15 0;
#P connect 14 0 11 0;
#P fasten 17 0 11 0 427 275 316 275;
#P fasten 16 0 11 0 348 275 316 275;
#P fasten 2 0 4 0 136 228 52 228;
#P connect 2 0 10 0;
#P fasten 2 0 14 0 136 226 316 226;
#P hidden connect 2 2 21 0;
#P fasten 2 1 19 0 188 224 223 224;
#P fasten 7 0 2 0 314 194 136 194;
#P fasten 8 0 2 0 386 197 136 197;
#P fasten 5 0 3 0 50 170 136 170;
#P fasten 0 0 6 0 136 109 50 109;
#P connect 0 0 3 0;
#P connect 6 0 5 0;
#P connect 25 0 5 0;
#P window clipboard copycount 28;
//-----begin draw_tiles_async.js
/*
takes a folder of movies and tries to asynchronously grab "thumbnails" from each. However, even though the JitterListener reports a "read", it doesn't seem to be able to immediately output a matrix.
*/
autowatch = 1;
outlets = 3;
mov = new JitterObject("jit.qt.movie");
mov.autostart = 0;
mov.adapt = 1;
var movlisten = new JitterListener(mov.getregisteredname(), thecallback);
var movepath;
var counter = 0;
var total = 0;
var TASK_INTERVAL = 1;
var DRAWIT = new Task(readtask,this);
var clips = new Array();
var tmpmatrix = new JitterObject("jit.matrix");
function drawtiles(topath){
counter = 0;
var g = new Folder(topath);
g.typelist = ["MooV","mpg4","dvc!","MPEG","MPGa","MPGv","MPGx","SWFL","SWF","JPEG","GIF","GIFf","PNG","PNGf","8BPS","TIFF","TGA","PICT","SWF","BMPf","BMP","qtif","SGI","TPIC","PNTG","qdgx","PFix","PICS","MP3","MPG3","AIFF","WAVE","Mp3 ","????"];
total=g.count;
outlet(1,total);
if(g.count){
for (var i=0;i< g.count;i++) {
g.next();
var thefile = g.pathname+"/"+g.filename;
clips[i] = thefile;
post("filling array: ",i,thefile,"
");
}
g.close();
}
movepath = topath;
if (!DRAWIT.running){
DRAWIT.execute();
}
}
function readtask(){
mov.asyncread(clips[counter]);
}
readtask.immediate = 1;
function thecallback(event)
{
if (event) post("
listen",event.eventname);
if (event.eventname=="read"){
mov.frame(30);
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
outlet(2,counter);
counter++;
if (counter<total&&!DRAWIT.running) DRAWIT.execute();
}
}
function bang(){
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
}
function readit(v){
mov.read(clips[v]);
mov.frame(30);
mov.matrixcalc(tmpmatrix,tmpmatrix);
outlet(0,"jit_matrix",tmpmatrix.name);
}
//end draw_tiles_async.js
--
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
The Lifespan
2 oz brandy
1/2 oz orgeat
1/2 oz maraschino
3/4 oz mix of (meyer) lemon and (yellow) grapefruit juice
Shake with ice and serve in a Pernod-rinsed cocktail glass
- Previous message: [javascript-dev] Re: JitterListener and jit.qt.movie read...bug?
- Next message: [javascript-dev] Re: JitterListener and jit.qt.movie read...bug?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
