What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed

[REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed
Author: Message:
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
31 / Male / Flag
Joined: Apr 2004
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed
Matty, you should be aware that you have to declare your onreadystatechange event BEFORE you call xml.load(). So, either you simply place the contents of the createXml function in the timer event, or you add the callback function as a parameter to the createXml function and assign it to onreadystatechange in the createXml function.

I already explained this in Mattike's reply to XMLHTTP Not Loading After Save. The thing is that if you declare it after the load() function, there's a (small) chance that the asynchronous XML loading is faster than the process of the script.

code:
...

function createXml(url, funcReadyStateChange) {
    Interop.Call('wininet.dll', 'DeleteUrlCacheEntryW', url);
    xml = new ActiveXObject('Microsoft.XMLDOM');
    xml.async = true;
    xml.onreadystatechange = funcReadyStateChange;
   
    xml.load(url);
    return xml;
}

function OnEvent_Timer() {
    var xml = createXml('http://bbc-hackday.dyndns.org/tracks/radio1.rss', function() {
        if (xml.readyState === 4)
            var newPsm = xml.selectSingleNode('//rss/channel/item/dc:creator').text+' - '+xml.selectSingleNode('//rss/channel/item/dc:title').text;
            Debug.Trace(newPsm);
            if (sPsm !== newPsm) {
                Messenger.MyPersonalMessage = newPsm;
                sPsm = newPsm;
            }
        xml = null;
    });

    MsgPlus.AddTimer('grabSong', 60000); // one minute
}
Also, I don't really know for the XMLDOM but I think you should also check the xml.status to see if it equals 200 (xml.status === 200) in the event. I don't really know if it functions like the XMLHTTP, but the xml.readyState documentation says:
quote:
Originally posted by DevGuru XML DOM :: readyState
  • ...
  • COMPLETED(4)
    the document has been completely loaded, successfully or unsuccessfully.

Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
02-11-2008 08:32 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »

Messages In This Thread
[REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by webbo04 on 02-11-2008 at 04:17 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by Spunky on 02-11-2008 at 04:29 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by webbo04 on 02-11-2008 at 04:35 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by MeEtc on 02-11-2008 at 05:06 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by Stigmata on 02-11-2008 at 06:07 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by Spunky on 02-11-2008 at 06:32 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by matty on 02-11-2008 at 06:38 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by webbo04 on 02-11-2008 at 07:06 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by matty on 02-11-2008 at 07:40 PM
RE: [REQ] BBC Radio 1 Now Playing Script. Simple Rss Feed - by Matti on 02-11-2008 at 08:32 PM


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On