A number of functions will return an Object, which is an easy way to send a number of mixed variables all packaged up within a single "thing." The file "readme.js" is used by the example pages. It contains a number of functions that are useful for rendering data to the page.
Objects are useful when all of the variables are not "pre-determined" -- as is the case with a playlist <item>. As you know, a playlist <item> can contain any number of <tags>
For example, if we are using an XML playlist and one of our items is set up as follows:
<item>
<filename> example2.flv </filename>
<artist> Killeen and Gieson </artist>
<title> Example 2 </title>
<link> http://www.plaino.com</link>
<image> example2.jpg </image>
<someOtherTag> whatever </someOtherTag>
</item>
... then the returned object will contain variables according to the same structure as:
returnedObject.filename = "example2.flv"
returnedObject.artist = "Killeen and Gieson"
returnedObject.title = "Example 2"
returnedObject.link = "http://www.plaino.com"
returnedObject.image = "example2.jpg"
returnedObject.someOtherTag = "whatever"
Perhaps the easiest way to see how to get the data out of the variable is to check out the "displayObject" function that is found within "readme.js."
function displayObject(returnedObject){
// Create a string variable so we can put the
//
information into a variable and print it out later:
var retText = "";
// "prop" is the name of the variable
for(var prop in returnedObject){
// Here we are "printing" the "prop" variable name,
// the retrieving the "prop" from the object using
// [brackets] to access the variable name within the object
retText += "<b>" + prop + "</b> : " + returnedObject[prop] + "<br>";
}
// Here we "print" retVal to the screen using the "writeIt" function
writeit(retText,"trackInfo");
}