Page 1 of 2

Users of Sonos ZonePlayers Needed for Testing

Posted: Thu Nov 16, 2006 3:53 pm
by Osler
If you own a Sonos system (http://www.sonos.com) your help would be appreciated. I have created a set of scripts that will allow HouseBot to control a Sonos system. Testing of the scripts would be greatly appreciated.

Whats included:

ZonePlayer_Discovery script that is used during inital set up to identify the ZonePlayers in the system and obtain information needed by the control scripts.

ZonePlayer_<ZoneName> scripts. Each zone requires its own script for control. Several zone scripts have been included as well as a generic script that can be modified for your particular zone naming scheme.

Each script requires its own Execute Program Device. Additionally, an External Control Device is also required (Port: 2525, IP: 127.0.0.1, Password: <none>).

Detailed instructions are included in the .zip file.

Current Capabilities:
Play
Pause
Stop
Next
Next Section
Previous
Previous Section
Volume (accepts a value from 0 to 100)
Treble (accepts a value from 0 to 10)
Bass (accepts a value from 0 to 10)
Mute
Loudness
Current Track (given as track number currently)
Track Length
Track Position

The next step is providing the ability to link zones. This will be easy to do, I just need to find the time.

I can access track metadata so I will also be adding track information (artist, album, song, etc.) - just need the time.

Queue population via HouseBot should be doable. However, this will be on down the line.

Enjoy,

Osler

(Scott, can you host this zip file?)
Download zip file here:

Posted: Fri Nov 17, 2006 8:54 pm
by ScottBot
Now that I've finally fixed the forum so attachments work again, I'm just going to provide it in this message. Note, you must be logged in to see the attachment.

Mute and Loudness

Posted: Sat Nov 18, 2006 4:15 pm
by Osler
There are some problems with the code for set mute and loudness. Sorry I didn't catch this earlier, but I am just now having a chance to put the scripts through their paces via HouseBot. I will get the problem fixed and update the Sonos_Control.zip file. I'll post when its updated.

Osler

Posted: Sat Nov 18, 2006 5:02 pm
by Osler
All fixed for now:

Fixes:
1) ZonePlayer not receiving boolean value for LoudnessStatus
2) ZonePlayer not receiving boolean value for MuteStatus
3) Treble defaulted to 0 no matter what value was entered
4) Bass defaulted to 0 no matter what value was entered

All appears to be working as advertised now. I download the .zip from the forum to my main system today and did the "installation" of the scripts. I am currently controlling two ZonePlayers from HouseBot.

I have figured out how to get music library information by Album, AlbumArtist, Genre, etc. from the ZonePlayer. This is the first step in being able to build a Queue from within HouseBot. The only problem is that this data comes from the ZonePlayer in xml format and I have never really had the need to learn how to parse this stuff (please see my poor attempt at a non-xml weather scraper). This also means I will have to learn about the HouseBot alpha-list and list control, which I have been avoiding like the plague.

Osler

Hmm....no attachment. Please see link in first post above for latest version.

Check sonos forums too

Posted: Mon Nov 20, 2006 12:14 am
by gfarrar
Hi,

You may also want to check the Sonos forums for volunteers:

http://forums.sonos.com

Looks like a cool integration.

Best,
Graham
Manager, Sonos Support

Posted: Mon Nov 20, 2006 5:01 pm
by Osler
Thanks Graham. I was planning to do this once a few more kinks are worked out. I am in the midst of rewriting the scripts to condense the code and fix a problem with the UPnPDeviceFinder.FindByUDN that I encountered. Once I get it to a relatively stable position I'll make the request there.

Osler

Posted: Mon Nov 20, 2006 10:34 pm
by Osler
See link in first post for the latest scripts.

I have condensed the code and used only one CreateObject call for UPnPDeviceFinder for the entire script. The previous script acted a little squirrely when trying to attach to one of my ZonePlayers...not sure why but it appeared to be related to the multiple FindByUDN calls in the previous version. The script now attempts some error catching and if the CreateObject doesn't work, it will attempt it three additional times before producing an error and a message box.

Osler

Posted: Sat Nov 25, 2006 6:33 pm
by Osler
Scripts updated with new functionality.

An additional property needs to be created called ZPCurrentAlbum (alphanumeric) and this property added to each ZonePlayer_<ZoneName> device. Scripts will now populated Album-Artist in this field and the ZPCurrentTrack property will display the track which is currently playing in the queue. This only works on queues >1 track in size....I haven't spent the time yet to figure out why a 1 track queue causes problems.

The main functionality of each script has been placed in a Do/Loop which occurs every 500 ms (thanks Richard for posting your scripts....much goodness is in those). This means that once the script is executed, it continues indefinately and allows for continuous polling of the physical ZonePlayer device. Benefits include:

1) CurrentPosition property increments as the track plays
2) Once you change a property value (TransportState, Mute, etc.) the change is automatically detected by the script and transferred to the ZonePlayer
3) Changes made by controllers external to HouseBot (Sonos Handheld Controller, Sonos Desktop Controller) are detected by the script and the property values in HouseBot are updated to reflect the current ZonePlayer state

Additional base scripts are now available to match every feasable zone name that is available to Sonos users in the US during inital zone set-up.

Please see the download link in the first post for the latest scripts.

Osler

UPDATE

Posted: Sun Dec 03, 2006 11:29 pm
by Osler
I have successfully parsed through all of the media (tracks) available to the Sonos network and obtained basic information as well as the track URI and metadata (both needed to populate a queue or use the "play now" function of the ZonePlayer). I have to say that after learning to parse XML for the last few days, there comes a point where you say "DOH" and feel somewhat dense as understanding begins to dawn on you.

Additionally, I have figured out how to link ZonePlayers together....the most important function being to create a "Party Mode" where all ZonePlayers play the same thing simultaneously.

I am currently working on an integrated script to control all ZonePlayers on the network. This should simplify things considerably.

The ZonePlayer_Discovery script will undergo some changes as well.

I will write an additional script that will pull all data from media shares and populate a database file for queue population. This script will also serve to reindex the media shares/update the database as new albums/tracks are added.

This would be much easier if I had the Visual Basic SDK.....ahhh, to wish.

Hopefully I can get this completed in the next week or so.

Osler

UPDATE

Posted: Wed Dec 13, 2006 11:52 pm
by Osler
I got a little side-tracked trying to write an AcitveX DLL to allow scripting using the UPnP.dll from within HouseBot. It worked to a point, but not all of the methods of the UPnP.dll are available in VB6....most importantly the capability to do device discovery. As a result, I have moved the code back to VBScript and written a class that allows for much simplifed control of a ZonePlayer via scripting. I will post the methods of the class soon. If you have a scripting tool such as VBsedit, it should expose the methods once the class object is created. The class exposes all ZonePlayer parameters I would conceivably want to control or perform a state query on.

Sample code using class:

My goal is to try to keep this modular and use .wsf files to pull in the class files. However, you can simply cut-and-paste the attached script into your current script and use it that way. THIS SCRIPT WILL NOT WORK FROM WITHIN HOUSEBOT. It has to be called with wscript.exe using command line paramters.

Download Class:



Osler

Posted: Thu Dec 14, 2006 11:29 pm
by Circe640
Osler,
I still have the VB SDK and been using it to build my plugin so I know its capabilities well. I also have an integrated qplayer in the plugin about to be released. IF you use you XML to populate my plugin DB for song data the Qplayer in it could be used to drive your other parts. Let me know if you are interested.

Jim

Posted: Thu Dec 14, 2006 11:31 pm
by Circe640
Osler,
I have the VB SDK and know its capabilities well. As I have been using it to build MediaPro. MediaPRo has a Qplayer that would work extreme;y well for what you described. Let me know if you are interested

Jim

Posted: Thu Dec 14, 2006 11:35 pm
by Circe640
sorry for the double post but when I submit I am getting

Could not connect to smtp host : 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

DEBUG MODE

Line : 112
File : smtp.php

Posted: Fri Dec 15, 2006 12:49 am
by Osler
I'd be very interested. Building the XML parsing class is next on my list of things to do. You have pm.

Osler

Posted: Fri Dec 15, 2006 8:11 am
by ScottBot
Circe640 wrote:sorry for the double post but when I submit I am getting

Could not connect to smtp host : 10060 : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.

DEBUG MODE

Line : 112
File : smtp.php
Thanks for mentioning this Jim. I've been seeing double-posts and had no idea what was going on. If other users are seeing the same errors, it would explain things. I've started looking into this, but if anyone else has had similar issues, please let me know ASAP.