2006-03-09, 20:22
you sure like to argue dontcha ?
note the " "
note the " "
(drakethegreat @ mar. 09 2006,16:19 Wrote:oops. of course i did.(jiz_king @ mar. 09 2006,13:14 Wrote:the ps2's browser has good js support i think. and with wifi built in it'd be a great remote.did you mean the psp?
Quote:- getcurrentlyplaying (that's more efficient than the current one! and includes all tag info/thumbfilename)
- getplaylistcontents (that's got more detail)
Quote:getthumbnail (since the file is off somewhere, what i did was filecopy to the q:\web directory to a temp file )the method i'm using now to get the images does not cache anything so it will download a new image every time the track changes even if it is the same image. if you give the browser an actual url to the image it will be cached automatically.
Quote:json-rpc is lightweight remote procedure call protocol similar to xml-rpc. it's designed to be simple!
Quote:--> { "method": "echo", "params": ["hello json-rpc"], "id": 1}
<-- { "result": "hello json-rpc", "error": null, "id": 1}
Quote:{"menu": {
"id": "file",
"value": "file:",
"popup": {
"menuitem": [
{"value": "new", "onclick": "createnewdoc()"},
{"value": "open", "onclick": "opendoc()"},
{"value": "close", "onclick": "closedoc()"}
]
}
}}
Quote:<menu id="file" value="file" >
<popup>
<menuitem value="new" onclick="createnewdoc()" />
<menuitem value="open" onclick="opendoc()" />
<menuitem value="close" onclick="closedoc()" />
</popup>
</menu>
Quote:title: xml is so 1999... json is where it's at!
body:
or so these guys would have you thing:
http://www.json.org/
http://en.wikipedia.org/wiki/json
the real benefit is this:
let's say you're doing some ajax stuff to get back a list of people:
Quote:<people>
<person id="1" name="joe blow" />
<person id="2" name="john smith" />
</people>
the equivalent json would be something like this:
Quote:{let's say you need to cycle through the people and build a list of people with links to their name.
"people" :
[
{ "id": "1", "name": "joe blow" },
{ "id": "2", "name": "john smith" }
]
}
the javascript would be something like this for xml (not cross browser, required work for mozilla due to it's xml differences):
Quote:function makepeoplestringfromxml( xml )the javascript for json would be (note that there're some security issues with this, but it's a one line change and a js include file, but it's trivial):
{
// assume the xml is not in a dom already
var dom = new activexobject( "microsoft.xmldom" );
dom.loadxml( xml );
var nodes = dom.selectnodes( '/people/person' );
var resstring = "";
for( var i=0; i<nodes.length; i++ )
{
resstring += "<a href='viewperson.aspx?id=" + nodes[i].attributes['id'].value + "'>" +
nodes[i].attributes["name"].value + "</a>";
if ( i != nodes.length-1 )
resstring += "<br>";
}
return resstring;
}
Quote:function makepeoplestringfromjson( json )
{
var people = eval('(' + json+ ')');
var resstring = "";
for( var i=0; i<people.length; i++ )
{
resstring += "<a href='viewperson.aspx?id=" + people[i].id + "'>" +
people[i].name + "</a>";
if ( i != people.length-1 )
resstring += "<br>";
}
return resstring;
}
note that the major differences are:
- crossbrowser for free (xml is way different in firefox than ie)
- no activex/com objects being created
- no xpath! (which actually can be a con, because there's a lot of times where i want to get the people with some attribute and it's obviously easier in xpath)
- no xsl transforms available (but they should be avoided in javascript anyway)
- the json method creates a lightweight object with properties that can be held onto/used in a variety of ways... holding onto an xml dom in javascript is one way to suck a lot of memory up quickly.
google and yahoo are using a combination of xml and json, so it does have some larger users out there...
just thought i'd throw this to ya'll to get your thoughts...
(affini @ mar. 10 2006,20:15 Wrote:my question would be...the ol' crystal ball is a little murky these days, but:
is json the way the "top" players (i.e. yahoo, google, etc) are moving forward or are they sticking with xml amily and json sparcely?
i'd say stick with what the future is and what is most cross browser compatible since you never know what browser may be on top next :lol:
Quote:cstdstring fn=g_application.currentfile();this is where we get sticky... this can be optimized to currentfileitem() which will speed up the stuff below as the fileitem has the tag on it and stuff.
Quote:tmp.format("%i",g_playlistplayer.getcurrentsong());gotta do this...
output+=closetag+opentag+"songno:"+tmp;
Quote: int64)(g_application.gettime() * 10);get the current tag (which is on currentfileitem, so this call is somewhat redundant, but is in memory, so ok...)
output+=closetag+opentag+"type"+tag+":audio";
const cmusicinfotag& tagval=g_infomanager.getcurrentsongtag();
if (tagval.gettitle()!="")
output+=closetag+opentag+"title"+tag+":"+tagval.gettitle();
if (tagval.getartist()!="")
output+=closetag+opentag+"artist"+tag+":"+tagval.getartist();
if (tagval.getalbum()!="")
output+=closetag+opentag+"album"+tag+":"+tagval.getalbum();
if (tagval.getgenre()!="")
output+=closetag+opentag+"genre"+tag+":"+tagval.getgenre();
if (tagval.getyear()!="")
output+=closetag+opentag+"year"+tag+":"+tagval.getyear();
Quote: if (!g_infomanager.getmusiclabel(211).isempty())these two operations actually do some calculation for what should be a static field... i'd say that these values should be calculated once and cached.
output+=closetag+opentag+"bitrate"+tag+":"+g_infomanager.getmusiclabel(211); // musicplayer_bitrate
if (!g_infomanager.getmusiclabel(216).isempty())
output+=closetag+opentag+"samplerate"+tag+":"+g_infomanager.getmusiclabel(216); // musicplayer_samplerate
}
Quote:ouch... this hits the filesystem each time! get once, then cache it.
if (fn.find("://")<0)
{
cstdstring thumb;
cutil::getthumbnail(fn,thumb);
if (!cfile::exists(thumb))
thumb = "[none] " + thumb;
output+=closetag+opentag+"thumb"+tag+":"+thumb;
}
Quote: if (g_application.m_pplayer && g_application.m_pplayer->ispaused())gotta do this...
output+=closetag+opentag+"paused:true";
else
output+=closetag+opentag+"paused:false";
if (g_application.isplaying())
output+=closetag+opentag+"playing:true";
else
output+=closetag+opentag+"playing:false";
Quote: if (lpts!=-1)yeesh... can't we pass ms to the client and let them do this :d
{
int hh = (int)(lpts / 36000) % 100;
int mm = (int)((lpts / 600) % 60);
int ss = (int)((lpts / 10) % 60);
if (hh >=1)
{
tmp.format("%02.2i:%02.2i:%02.2i",hh,mm,ss);
}
else
{
tmp.format("%02.2i:%02.2i",mm,ss);
}
output+=closetag+opentag+"time:"+tmp;
Quote: cstdstring strtotaltime;err, isn't this the same code as above? i'd bet that there's a common method somewhere for this! i didn't look at the gettotaltime call, but i'd bet that's cached already...
unsigned int tmpvar = (unsigned int)g_application.gettotaltime();
if(tmpvar != 0)
{
int hh = tmpvar / 3600;
int mm = (tmpvar-hh*3600) / 60;
int ss = (tmpvar-hh*3600) % 60;
if (hh >=1)
{
tmp.format("%02.2i:%02.2i:%02.2i",hh,mm,ss);
}
else
{
tmp.format("%02.2i:%02.2i",mm,ss);
}
output+=closetag+opentag+"duration:"+tmp;
}
Quote: tmp.format("%i",(int)g_application.getpercentage());the effectiveness of this depends on the player... i didn't look at the mplayer code to see what it does here...
output+=closetag+opentag+"percentage:"+tmp;
Quote: _int64 fs=filesize(fn);ouch! another fs hit... this data is actually already stored in the fileinfo object: __int64 m_dwsize;
if (fs>-1)
{
tmp.format("%i64d",fs);
output+=closetag+opentag+"file size:"+tmp;
}
}