Several forum members are using the WebLogger plugin to display whats currently playing on their Squeezeboxes on their personal web sites.
My philosophy: Why spend five minutes implementing a perfectly functional existing solution when you can spend 30 or 40 hours doing a substandard version of the same thing from scratch? Im not a PERL programmer, but I deduced from looking at the scripts for WebLogger that it relied on a technique to similar to the one employed in KDFs Execute Script plugin to ascertain when SlimServer played files. The Execute Script plugin listens for various SlimServer events and then executes scripts when the events fire. I was already using Execute Script, and it seemed like it would be fairly straightforward to write a script to update a page on our web site that would execute on SlimServers Play, Stop and Squeezebox Power Off events. Taking a look at the Technical Information link on the SlimServer web interface, I learned about SlimServers XML skin. By browsing to: http://localhost:9000/xml/status.xml, I found that the XML returned from this URL contained all of the information that I wished to display on our web site. So, I set about writing a script that would read the current status XML, extract the desired data, insert the data into a much simplified XML structure, post the XML to our web site, and then FTP the current cover image, should one exist. It took quite a while to debug, but the script itself was not too difficult to produce. Getting it to run with the Execute Script plugin was another story. It simply would not work. Double-clicking on the script worked fine, but using the Execute Script plugin, my script hung trying to load the XML from status.xml. I still dont know what the issue is (although I assume its permissions-related), but eventually I had to look for a workaround. I tried all sorts of options, calling my script in a batch file, moving the portion of my code that would not run into an executable, etc., but all attempts failed. Finally, I focused on the Task Scheduler. I had discovered earlier that running the script as a Scheduled Task worked. I started looking around for information about scripting the task scheduler. My plan was to have the Execute Script plugin execute a script that instructed the Task Scheduler to launch my script. My SlimServer is running on a Windows 2000 box. Scripting the Task Scheduler on Windows 2000 is possible, but not extremely pretty. And while I found how script the creation of a task, I couldnt find a means of scripting a command to run this task now. XP, however, includes an application called schtasks.exe that can be scripted to run a task immediately. Officially, this program runs only on XP and higher, but I found a tip about using a hex editor to make a slight change to the program that allows it to run under Windows 2000. Once I got the task scheduling and executing squared away, I had a little trouble getting Execute Script to recognize the Play event. KDF helped me through that issue with some changes to the Execute Script plugin. I also made a few changes myself such as adding a handler for the Power Off event and suppressing the attempts by the script to display what its doing on the Squeezeboxs display. The one issue that I was not able to resolve other than through brute force was to update our web site when the Squeezebox had either stopped or was turned off. This is possible by using the CLI, but I have no knowledge in that area right now, so my brute force method is simply to check the Squeezebox every five minutes (with another task and script) to see if its either stopped or off. Heres the finished product. Hopefully, were playing something interesting if and when you have a look: http://www.theheals.org/jon/squeezebox_status.asp In the ZIP file below, Ive included all of the files for this status monitor in case anyone else wants to play with them. This is a Microsoft IIS/ASP/VBScript-based project. *UPDATE_SLIMSERVER_STATUS.vbs*: This is the main script that loads the status XML, extracts the needed data, inserts the data into a much simplified XML structure, posts the XML to our web site, and then FTPs the current cover image. It's scheduled to run at system startup and just sits there otherwise until called upon. *UPDATE_NONPLAYING_STATUS.vbs*: This script notifies our web site if the Squeezebox has either stopped or is off. It runs from a scheduled task every five minutes. *LAUNCH_UPDATE_TASK.vbs*: This script instructs the Task Scheduler to run the UPDATE_SLIMSERVER_STATUS.vbs script immediately. *Execute.pm*: My modified version of KDFs script (1.7) for SlimServer 6.2.x that includes an extra event to listen for: Power OFF and also changes 1) to listen for the Play event, and 2) activate the script on initialization. KDF has a different version of the script for SlimServer 6.5. On our web site: *now_playing.xml*: The XML file that contains data about SlimServers status. *recently_played.xml*: Im also tracking the last 20 items played on the Squeezebox. *update_now_playing_xml.asp*: This page accepts the posted XML from the UPDATE_SLIMSERVER_STATUS.vbs script and saves it to now_playing.xml. *now_playing.asp*: This is a two-frame frameset document. It is designed to appear in a 383px by 425px iframe on another page (in my case, slimserver_status.asp). *now_playing_details.asp*: This document displays SlimServers now playing status and loads into the top frame of now_playing.asp. It includes code to make every attempt to always load fresh stuff and not rely on the browsers cache. *now_playing_monitor.asp*: This page resides in the bottom 0px frame of now_playing.asp, and is invisible to the user. It reloads every ten seconds and compares the state of now_playing.xml with values stored in Session variables. If it detects a change, it forces now_playing_details.asp to reload. If everything works as its supposed to, our web site is never more that ten seconds behind whats actually happening on the Squeezebox. *recent_selections.asp*: This page displays the 20 most recently played selections. +-------------------------------------------------------------------+ |Filename: now_playing.zip | |Download: http://forums.slimdevices.com/attachment.php?attachmentid=1154| +-------------------------------------------------------------------+ -- jonheal Jon Heal says: Have a nice day! http://www.theheals.org/ ------------------------------------------------------------------------ jonheal's Profile: http://forums.slimdevices.com/member.php?userid=2133 View this thread: http://forums.slimdevices.com/showthread.php?t=22666 _______________________________________________ Discuss mailing list Discuss@lists.slimdevices.com http://lists.slimdevices.com/lists/listinfo/discuss