PDA

View Full Version : controlling squeezebox/slimserver from my own app



Howard Durdle
2004-08-12, 01:38
> at all). If someone has done something like this, or if you
> have any good ideas, please let me know.

As someone else has already mentioned, the XML interface allows for lots of
information and a great deal of control over the SB.

I've coded an ASP application that uses the XML skin to interrogate the
database and control the players. It was primarily written so that I could
query the server from my mobile phone.

Now, if I'm in a record shop and think "Have I got this already..?" I can
check via WAP/WML on my mobile!

Because searching the database by artist is quite an intensive task (on
Windows at least) I cache the results to local XML files, which are then
parsed by my app. They have a "Time to Live" before expiring and being
re-queried. That way if people query the same results, it's much faster to
respond!

The app recognises the caller-ID of the mobile phone connecting, and bounces
anyone who isn't me. :)

Using ASP, and XMLDOM, makes it very easy to parse the SlimServer XML.
Anything you can do with the standard skin, you can do via XML.

If you want any code snippets or further info, contact me off-list.

All the best,
Howard

mickweight
2006-07-31, 04:38
Haward,

You mentioned controlling slim server from an ASP application, but I am having problems doing this.

I am using the DOM model within an ASP (VB Script) to generate an http request and assign the response to an MSXML object, but it always returns an error. The code runs fine from a VB Script file executed from my desktop, so I'm thinking it must be some kind of permissions issue with my ASP page making the request. Initially I just want to do a simple query to get the current play list back, once I have this working I'll expand to deal with adding and removing items from the playlist etc...

jonheal
2006-07-31, 06:00
Haward,

You mentioned controlling slim server from an ASP application, but I am having problems doing this.

I am using the DOM model within an ASP (VB Script) to generate an http request and assign the response to an MSXML object, but it always returns an error. The code runs fine from a VB Script file executed from my desktop, so I'm thinking it must be some kind of permissions issue with my ASP page making the request. Initially I just want to do a simple query to get the current play list back, once I have this working I'll expand to deal with adding and removing items from the playlist etc...
MSXML does not recognize status.xml as valid XML. I solved this by opening ..\SlimServer\server\HTML\xml\status_header.html and changed this:

<?xml version="1.0" encoding="[% LOCALE %]" standalone="no"?>

<!DOCTYPE status SYSTEM "html/slimserver_xml.dtd">

<status xmlns="http://www.slimdevices.com/slimserver/xml">
<players>
<playercount>[% playercount | html %]</playercount>
<player>

...

To this:

<?xml version="1.0" encoding="[% LOCALE %]" standalone="no"?>

<status>
<players>
<playercount>[% playercount | html %]</playercount>
<player>

...

In other words, I removed the DOCTYPE and namespace declarations. They don't seem to be necessary for Slimserver to operate properly, and after the change, the XML can be parsed.

mickweight
2006-07-31, 06:09
thanks for the prompt response, I'll give that a try this evening

jonheal
2006-07-31, 07:22
thanks for the prompt response, I'll give that a try this evening
If you still have problems, I'll send you a script that works for me that you can use as a reference.

CardinalFang
2006-07-31, 10:23
> at all). If someone has done something like this, or if you
> have any good ideas, please let me know.

As someone else has already mentioned, the XML interface allows for lots of
information and a great deal of control over the SB.

I've been working on a new interface for the PSP based on OpenLazslo, which generates Flash files. It supports a database model that can take in XML files really easily by specifying the URL of where they are and data filters based on the hierarchy, so I managed to get the PC emulation up and running fairly quickly. Unfortunately the PSP implementation of Flash doesn't include the appropriate support for AJAX type functionaility yet, so no-go on the PSP until there's a new Flash upgrade...

You could build a pretty decent PC/MAc Flash application that controls SlimServer using OpenLazslo using this technology though.

Paul

mickweight
2006-07-31, 14:55
Still no joy with this problem.

the problem does not appear to be badly formed XML being returned (I've made the changes recommended)

the following code works in a .vbs file (with the exception of the response.write lines, but if I substitute them for msgbox commands it works correctly


################################################## ###########
' Create an instance of the MSXML Parser
Set MSXML = CreateObject("MSXML.DOMDocument")

' Set MSXML Options
MSXML.Async = False
MSXML.preserveWhiteSpace = False
MSXML.validateOnParse = false
MSXML.resolveExternals = False

' Form the request URL
XMLURL = "http://localhost:9000/xml/status.xml?p0=playlist&p1=add&p2=/1.wma;cauth=91e9d3f9707e2b5189ba7b60d983d24e"


' Issue the request and wait for the response
Loaded = MSXML.Load(XMLURL)

' If the request is loaded successfully, continue
If (Loaded) Then
response.write("success")
Else
response.write("fail")
End If

################################################## #####

also if I put the command

response.redirect "http://localhost:9000/xml/status.xml?p0=playlist&p1=add&p2=/1.wma;cauth=91e9d3f9707e2b5189ba7b60d983d24e"

into the asp page it displays the xml in my browser, also the command is actually executed and the track is added to the playlist, but I get the error condition back and no XML in my DOMdocument object so....
..

it doesn't appear to be permission related
it doesn't appear to be xml related

jonheal
2006-08-01, 05:29
Still no joy with this problem.

the problem does not appear to be badly formed XML being returned (I've made the changes recommended)

the following code works in a .vbs file (with the exception of the response.write lines, but if I substitute them for msgbox commands it works correctly


################################################## ###########
' Create an instance of the MSXML Parser
Set MSXML = CreateObject("MSXML.DOMDocument")

' Set MSXML Options
MSXML.Async = False
MSXML.preserveWhiteSpace = False
MSXML.validateOnParse = false
MSXML.resolveExternals = False

' Form the request URL
XMLURL = "http://localhost:9000/xml/status.xml?p0=playlist&p1=add&p2=/1.wma;cauth=91e9d3f9707e2b5189ba7b60d983d24e"


' Issue the request and wait for the response
Loaded = MSXML.Load(XMLURL)

' If the request is loaded successfully, continue
If (Loaded) Then
response.write("success")
Else
response.write("fail")
End If

################################################## #####

also if I put the command

response.redirect "http://localhost:9000/xml/status.xml?p0=playlist&p1=add&p2=/1.wma;cauth=91e9d3f9707e2b5189ba7b60d983d24e"

into the asp page it displays the xml in my browser, also the command is actually executed and the track is added to the playlist, but I get the error condition back and no XML in my DOMdocument object so....
..

it doesn't appear to be permission related
it doesn't appear to be xml related
Set MSXML = CreateObject("MSXML.DOMDocument")

...works in a VBScript file, but in an ASP, it must be written:

Set MSXML = Server.CreateObject("MSXML.DOMDocument")

I apologize if I've stated the obvious. :-)

mickweight
2006-08-01, 13:30
Hmmn, thanks for the tip, and you weren't stating the obvious as I hadn't read up on creating objects from asp pages. However, it still doesn't fix my problem.

I've experimented a bit more and I've made a valid xml file and stored it in my virtual directory.

If i reference it from my asp page using a real disc path eg c:\vdirectory\file.wma it successfully reads the file into the DOMdocument object.

BUT

If i reference it fro my asp page using an http reference path eg http://localhost/jukebox/file.wma it successfully reads the file into the DOMdocument object. (it still reads ok from vb script in either case).

I conclude that it has to be related to permissions or security. I'm using IIS for my web server and I'm running windows XP on a home network basis

Any other ideas?

thanks very much for your help by the way !

mickweight
2006-08-01, 13:57
Solved,

Thanks for all your help, but since posting the last message I believe I have found the cause of the problem..

A further review of the DOM object model revealed that I needed to use the set the property method of the DOM object to set the secondlevel property to ServerHTTPRequest=true.

this seems to have now enabled what is effectively a server to server http communication.

Thanks for all your help though..