Forums > Jitter

id3name.length

March 29, 2006 | 3:19 am

i’m playing with id3 tags in jit.qt.movie and javascript. I find that, whether or not it exists, the "length" of an id3 tag is always 1:
mov = new JitterObject("jit.qt.movie");
len = mov.id3artist.length
and len is always 1 for any file.
I was hoping that asking the length of the id3artist tag to test for its existence. Is there another way to test for its existenz?

below is a slightly modified version of the jitter-examples/javascript/video/jsmoviebank.js file that demonstrates this behavior. just save the below js and plug it into the moviebank example. watch the max window for evidence. this is on an XP Home box.

Peter

———————begin js———————
outlets = 3;

var vdim = [320,240];
var vindex = 0;
var vcount = 0;
var movarray = new Array();
var outmatrix = new Array();
var dummymatrix = new JitterMatrix(4,"char",vdim[0],vdim[1]);
var filenames = new Array();
// might want to try using an output array to avoid black flicker when switching movies

function bang()
{
if (vcount) {
movarray[vindex].matrixcalc(outmatrix[vindex]/*null*/,outmat rix[vindex]);
outlet(0,"jit_matrix",outmatrix[vindex].name);
} else {
outlet(0,"jit_matrix",dummymatrix.name);
}
}

function index(i)
{
if (i>=vcount)
i = vcount-1;
if (i<0)
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");
// load new movies
for (i=0;i
fold.next();
filenames[vcount] = fold.pathname + "/" + fold.filename;
movarray[vcount] = new JitterObject("jit.qt.movie");
movarray[vcount].autostart = 0;
id3art = movarray[vcount].id3artist; //ADDITION
post ("artist name is"+movarray[vcount].id3artist+" and length is: "+id3art.length,"n"); // ADDITION
rv = movarray[vcount].read(filenames[vcount]);
if (rv[1]==1) { // success, read returns an array [filename,success]
if (!outmatrix[vcount])
outmatrix[vcount] = new JitterMatrix(4,"char",vdim[0],vdim[1]);
outlet(1,"append",fold.filename);
movarray[vcount].matrixcalc(outmatrix[vcount]/*null*/,outmat rix[vcount]);
vcount++;
}
}
if (vindex>=vcount)
vindex = 0;
movarray[vindex].matrixcalc(outmatrix[vindex]/*null*/,outmat rix[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][messagena me])) {
movarray[vindex][messagename](a);
} else {
movarray[vindex][messagename] = a;
}
}

———————end js————————-


March 29, 2006 | 10:38 am

I don’t have a way to test this at this very second. Does mov.id3artist
return a valid string for you, when there is a tag? And what does it
return when not? I recently used js to get artist tags out of mp3 files,
and had no problems, but I wasn’t testing for their existence.

jb


March 29, 2006 | 4:35 pm

if the last "if" is a legit way to test if a string is valid (added to
my pvs js from the jsmoviebank.js example):

// load new movies
for (i=0;i
fold.next();
filenames[vcount] = fold.pathname + "/" + fold.filename;
movarray[vcount] = new JitterObject("jit.qt.movie");
movarray[vcount].autostart = 0;
id3art = movarray[vcount].id3artist; //ADDITION
post ("artist name is"+movarray[vcount].id3artist+" and length is:
"+id3art.length,"n"); // ADDITION
if (movarray[vcount].id3artist)
{
post("id3 is a valid string") }

then, yes, it returns a valid string.
or is there another way to test for a valid string? (I’m not very
fluent w/ these things!)

the result in the max window of that "middle" post on .mov files w/ no
id3 tags is:
artist name is and length is: 1

pn


March 29, 2006 | 4:52 pm

Try these tests:

function test()
{
var test1;
var test2 = "";
var test3 = "string";

if(test1) {
post("test1: " + test1.length + "n");
}
else if(test2) {
post("test2: " + test2.length + "n");
}
else if(test3) {
post("test3: " + test3.length + "n");
}
}

Only test3 passes.

wes


March 29, 2006 | 6:37 pm

ok, then here is a condensed version. the final test passes when i
send the message "grr dishes.mov", so i guess the artist tag, in spite
of not existing, returns a valid string.

var mov = new JitterObject("jit.qt.movie");
function grr(v) {
mov.vol = 0;
mov.autostart = 0;
mov.read(v);
var artist = mov.id3artist;
var album = mov.id3album;
var name = mov.id3name;
post(v+": "+"artist: "+artist+"album: "+album+"track: "+name,"n");
if (artist) { post("artist is a valid string","n") }
}


March 29, 2006 | 7:17 pm

This doesn’t happen for me in my tests. If perhaps you’re on XP, did
you miss the incremental update to jsjitter announced on this and the
MaxMSP list recently, which solves a problem that might be related.
It’s probably returning an array for you if you are using the older
jsjitter.

http://www.cycling74.com/twiki/bin/view/IncrementalDownloads

-Joshua


Viewing 6 posts - 1 through 6 (of 6 total)