Jump to content

How can I read this variable?


thesoundsmith

Recommended Posts

I have a pop-up page that plays music from my site, using the JWPlayer. I have not gotten clarity from their folks, so I'm asking for some help here, please. My goal is to create a small window that plays random musical selections from the site. This part works fine (go to my index page and click on the DashRadio link, the leftmost menu item. The "Buy" button currently opens the ZenCart shopping cart main page, but what I want is for either the Buy button or by clicking on the video itself, either way is fine, to link directly to the song download page (instead of www.thesoundsmith/cart, I go to http://www.thesoundsmith.com/private/zcart...products_id=239, different for each song.)The short XML file that feeds the player looks like this:

<?xml version='1.0' encoding='UTF-8'?><playlist version='1' xmlns='http://xspf.org/ns/0/'>  <trackList>	<track>	  <location>wavs/rad/lcancestors.mp3</location>		  <image>pix/lcicon.jpg</image>	  <title>Dance of the Ancestors</title>	  <annotation>Life Cycles</annotation>	 <link>http://www.thesoundsmith.com/private/zcart/index.php?main_page=product_music_info&cPath=62&products_id=240</link>	</track>	<track>	  <location>wavs/rad/lcyozho.mp3</location>		  <image>pix/lcicon.jpg</image>	  <title>Yo'zho'</title>	  <annotation>Life Cycles</annotation>	 <link>http://www.thesoundsmith.com/private/zcart/index.php?main_page=product_music_info&cPath=62&products_id=240</link>	</track>	<track>	  <location>wavs/rad/xfgeorgia.mp3</location>		  <image>pix/xfire50.jpg</image>	  <title>Georgia</title>	  <annotation>Crossfire</annotation>	 <link>http://www.thesoundsmith.com/private/zcart/index.php?main_page=product_music_info&cPath=62&products_id=239</link>	</track>	<track>	  <location>wavs/rad/xfgoinhome.mp3</location>		  <image>pix/xfire50.jpg</image>	  <title>Going Home</title>	  <annotation>Crossfire</annotation>	 <link>http://www.thesoundsmith.com/private/zcart/index.php?main_page=product_music_info&cPath=62&products_id=239</link>	</track>  </trackList></playlist>

'Location' is the MP3 file, and 'link' is the web address. I cannot seem to read the value for 'link' even though it is specified in the 'loadCheckedPlaylistData' function. First, I'd like to know what is being returned, but when I set an alert it does not fire. (it's possible that the URL needs to be escape-encoded, but I should still be able to read the line.Can someone show me how to view that data for the individual songs when selected, and/or show me what I'm doing wrong? It just does not seem that it should be this hard to view the data. Why does alert not fire here?

function loadCheckedPlaylistData() {	if (currentPlaylist) {		var j = 0;		var lst = new Array();		for(var i in currentPlaylist) {			if(document.getElementById('cb' + i).checked) {				lst[j] = {					author:currentPlaylist[i].author,					description:currentPlaylist[i].description,					duration:currentPlaylist[i].duration,					file:currentPlaylist[i].file,					link:currentPlaylist[i].link,					image:currentPlaylist[i].image,					start:currentPlaylist[i].start,					title:currentPlaylist[i].title,					type:currentPlaylist[i].type				}alert(lst[j]);				j++;			}		}		if(lst.length > 0) { player.sendEvent('LOAD', lst); }	}}

Sorry to sound so confused, it's just that - I am... :)

Link to comment
Share on other sites

If the alert doesn't fire that just means the if statement isn't true. So, this is not true:if(document.getElementById('cb' + i).checked)Make sure you're checking for Javascript errors also. When you're going through this loop:for(var i in currentPlaylist) {You may want to alert i so you can figure out which checkbox you're looking for on the next line.

Link to comment
Share on other sites

Thanks, justsomeguy. That is just what I need, some help in working with/understanding js debugging. I didn't write the script, and I 'assumed' (here we go again...) that because every <track> in the XML file had all the same pieces, it should work without errors. I'll keep plugging away. (And yes, Ben F. is correct...)<edit> Just realized, I already have the debugger installed, Firebug should solve my problem...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...