Would it be hard to have the start time and song length added to the XML? That would eliminate the need for polling at all...
Don't poll the XML file. It would be inefficient and could never work as accurately as the following system that is already in place.
It's not XML, but it's pretty easy to parse out:
http://www.wazee.org/bg_transport/currSong.phpSorry, I haven't jumped on the XML bandwagon yet, as most browsers don't have any real parsing implementation built into their javascript parsers yet. That url is the one your browser calls once per song to change the currently playing info at the top of all pages here on the site. Format is name=value;name2=value2; with the values being encoded for use in URL's.
Some values you'll be interested in:
song: the song title
artist: yeah
nextPacket: number of seconds until new data SHOULD be available. This is occasionally wrong, you should check the msid value to see if you actually received different data, and if not retry again after about 4 seconds.
displayTime: exactly when the song transition is estimated to occur. nextPacket will reach 0 about 24 seconds before the song actually changes on the stream, allowing any clients that are going to connect about 24 seconds to do it and still update on time. This way, the server does not get hammered with 100 requests for currSong.php at exactly the same time. Thus, when displayTime is > 0, you should wait this number of seconds before showing the popup, if you want it to come up exactly when the song transitions. (When displayTime <= 0 the song currently described in currSong.php has already been playing for -displayTime seconds.)
flexibility: recommended variation from nextPacket to make a new connection. If you anticipate many users of your application, please have your applications access this file every nextPacket + (a random decimal between 0 and 1 * flexibility) seconds.
Everything described above is implemented in javascript at
http://www.wazee.org/wazee.js in function handleSongPacket, in case that helps you to see what you should do.
Have fun
