Calling Sonos users

General HouseBot discussion. Any issues that don't fit into any of the other topics belong here.
supermangesthlm
Member
Posts: 7
Joined: Tue Aug 31, 2010 5:48 pm

Re: Calling Sonos users

Post by supermangesthlm »

lots of progress... will get back to you within 24hrs.. w/ idea.. (75% of my first post is about done).

Would like help about how to start a fav. radiostation.. im sure i could find it in ZonePlayerController.wsc.. but if you know..

also, is there a way to list savedques?

EDIT:Have not had time to test the new connect stuff... but wired / wifi dint make a difference..
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

To list your radio stations use this (note this will only list manually entered stations input by you via the PC controller):

Code: Select all

Dim ZonePlayer
Dim UDN
Dim Radio
Dim RadioSplit

UDN = "<your UDN here>""

Set ZonePlayer = CreateObject("ZonePlayer.Controller")


ZonePlayer.Connect(UDN)

Do Until ZonePlayer.Online = True
	WScript.Sleep 20
Loop

Radio = ZonePlayer.Browse("R:0/0", "0", "0")
RadioSplit = Split(Radio(0), vblf)
Dim I
For I = 0 To UBound(RadioSplit)
	WScript.Echo RadioSplit(I)
Next

ZonePlayer.Disconnect
Set ZonePlayer = Nothing
The following is an example of a single entry from the listed data that should be returned:

Code: Select all

x-rincon-mp3radio://208.80.52.106/CFNYFM?streamtheworld_user=1•102.1 FM- The Edge•R:0/0/18	102.1 FM- The Edge
The part you are interested in is this:

Code: Select all

x-rincon-mp3radio://208.80.52.106/CFNYFM?streamtheworld_user=1
This is the URI that needs to be passed via the "PlaySongNow" function:

Code: Select all

ZonePlayer.PlaySongNow("x-rincon-mp3radio://208.80.52.106/CFNYFM?streamtheworld_user=1", "")
ZonePlayer.SetTransportState("Play")

And this will list out all of your saved queues:

Code: Select all

Dim ZonePlayer
Dim UDN
Dim Playlist

UDN = "<your UDN here>"

Set ZonePlayer = CreateObject("ZonePlayer.Controller")


ZonePlayer.Connect(UDN)

Do Until ZonePlayer.Online = True
	WScript.Sleep 20
Loop

Playlist = ZonePlayer.Browse("SQ:", "0", "0")

WScript.Echo Playlist(0)

ZonePlayer.Disconnect
Set ZonePlayer = Nothing
You should recognize the format of these from my prior posts.

Osler
supermangesthlm
Member
Posts: 7
Joined: Tue Aug 31, 2010 5:48 pm

Re: Calling Sonos users

Post by supermangesthlm »

Getting "Error: UPnPDevice 'Children' not created." when i try ConnectSynchronously..

have also tried to send you a PM.. it ought to be in yr inbox..
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

Hmm...I just tried the new "ConnectSynchronously" function and it works just fine for me (return code = "OK" and commands are executed against the ZP).

Can you try using it on a different ZonePlayer? What type of ZonePlayer are you using to test against?

It appears to be connecting to the MediaServer portion of the ZP just fine, but can't connect to the MediaRenderer portion based upon the error that was thrown. I am not sure why...

Osler
supermangesthlm
Member
Posts: 7
Joined: Tue Aug 31, 2010 5:48 pm

Re: Calling Sonos users

Post by supermangesthlm »

The zp im dooin most testing against is a s5.
I have zp80 and zp90?, and zp120. havent had much chance testing against those... (one problem is that my ampless once are built in and hard to reach and i dont know what room a specific generation sits in.

(also getting choked on time now... But will hope to find more during next cpl of days)

(i think i need to as some sort of limit on the waiting for online look some scripts wait there forever...)
jed
Member
Posts: 3
Joined: Wed Feb 09, 2011 7:04 pm

Re: Calling Sonos users

Post by jed »

Hi,

I just wanted to pass on my thanks for providing this functionality to the Sonos community.

I recently got a couple of S5 players and have been playing around with your COM object.

Are you still interested in feedback? I'm currently writing a component wrapper around it to make it even easier to use. I'm doing this in Delphi but will probably also do one in C#. Is this ok?

I don't know when it will be ready for public consumption because like most, I'm always wanting more time in the day.

I may also have some questions along the way...

cheers,
Jeremy
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

Good luck to you. I have about 75% of a .net class completed that recapitulates the .wsc. Stay tuned as I am dusting it off to start working on it again. Wrapping the .wsc may be asking for some problems. If you have any, let me know and I will help as best I can.

Osler
jed
Member
Posts: 3
Joined: Wed Feb 09, 2011 7:04 pm

Re: Calling Sonos users

Post by jed »

Osler wrote:Good luck to you. I have about 75% of a .net class completed that recapitulates the .wsc. Stay tuned as I am dusting it off to start working on it again. Wrapping the .wsc may be asking for some problems. If you have any, let me know and I will help as best I can.

Osler
While I haven't tried to implement all features yet, the only one I'm currently have issues with is setting the master volume. I do need to look a little closer at it because I'm sure its user error!

Is there a way to find out which track is next in the queue to be played? Nothing popped out at me.

So far I've had no connection or stability issues at all. Working really well.

I won't bother with a C# port since you look to have it covered. I actually want to integrate it into my "iTunes" clone that I wrote (writing). Started because I wanted something to sync my music with my android phone.

EDIT: Volume issue solved. Needed to use SmallInt instead of Integer.
jed
Member
Posts: 3
Joined: Wed Feb 09, 2011 7:04 pm

Re: Calling Sonos users

Post by jed »

I've just learned a whole lot more about upnp devices that I think I ever wanted to!

Interesting indeed.
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

I just found that storing the total number of tracks as an integer presents a problem if you have > ~64,000 tracks. Just an FYI if you have more tracks than this and attempted to sort you music collection by tracks...you will get an error. I am working on a fix for this and will post an updated script once I have time to poor over the script and change all of my CInt() to CLng().

Osler
TonyG
Member
Posts: 94
Joined: Wed Jul 22, 2009 7:35 am

Re: Calling Sonos users

Post by TonyG »

Hi Osler
Good luck to you. I have about 75% of a .net class completed that recapitulates the .wsc. Stay tuned as I am dusting it off to start working on it again.
Any news?!

I'm brushing the dust off my Housebot manual ready for a funky new build on an Asus EP121 tablet. Your Sonos solution is one of the main applications, so looking to use the "latest and greatest" from your good self....

Tony
dhts
Member
Posts: 2
Joined: Wed Jul 13, 2011 10:46 am

Re: Calling Sonos users

Post by dhts »

Firstly as it's my first post a big thank you to Osler for the Sonos COM Object. It's probably meant I'm sticking with my Sonos and adding my own wall mounted controls rather than buying a Nuvo music system.

I've implemented much of what I need, though there's two things I'd welcome some input on.

By way of background I'm producing a vb.net program which talks to KNX devices (display and buttons) to control the Sonos. I invoke the Sonos by calling short VBscript scripts to perform a specific task - volume up, play track x etc. It's not particularly elegant or fast but it was within my technical reach !

Firstly I'm finding that seektrack isn't working reliably. I can't pinpoint the circumstances it does and doesn't work but if I've an album in the queue with the first track playing and I action the following neither the Next or Seektrack work. Next returns 'OK', and Seektrack returns:"-2147220625 Unknown Error"

The code is:
Dim FamilyRoom 'As ZonePlayer.Controller
Set FamilyRoom = CreateObject ("ZonePlayer.Controller")
MsgBox(FamilyRoom.Connect("uuid:RINCON_000E5810E40C01400"))
Do Until FamilyRoom.Online = True
WScript.Sleep 20
counter = counter + 1
Loop
msgbox("About to do next")
msgbox(FamilyRoom.SetTransportState("Next"))
msgbox("About to seek to 5")
MsgBox(FamilyRoom.seektrack(5))
FamilyRoom.Disconnect

Secondly, what's the best approach to doing something a little more elegant so that if I hit the volume up button 3 times, I don't have to call the volume up script 3 times each time connecting to the Zoneplayer. I guess I'm asking if there's a ready method for calling the Sonos COM object directly from VB.NET.

Many thanks,
Dave
dhts
Member
Posts: 2
Joined: Wed Jul 13, 2011 10:46 am

Re: Calling Sonos users

Post by dhts »

Firstly as it's my first post a big thank you to Osler for the Sonos COM Object. It's probably meant I'm sticking with my Sonos and adding my own wall mounted controls rather than buying a Nuvo music system.

I've implemented much of what I need, though there's two things I'd welcome some input on.

By way of background I'm producing a vb.net program which talks to KNX devices (display and buttons) to control the Sonos. I invoke the Sonos by calling short VBscript scripts to perform a specific task - volume up, play track x etc. It's not particularly elegant or fast but it was within my technical reach !

Firstly I'm finding that seektrack isn't working reliably. I can't pinpoint the circumstances it does and doesn't work but if I've an album in the queue with the first track playing and I action the following neither the Next or Seektrack work. Next returns 'OK', and Seektrack returns:"-2147220625 Unknown Error"

The code is:
Dim FamilyRoom 'As ZonePlayer.Controller
Set FamilyRoom = CreateObject ("ZonePlayer.Controller")
MsgBox(FamilyRoom.Connect("uuid:RINCON_000E5810E40C01400"))
Do Until FamilyRoom.Online = True
WScript.Sleep 20
counter = counter + 1
Loop
msgbox("About to do next")
msgbox(FamilyRoom.SetTransportState("Next"))
msgbox("About to seek to 5")
MsgBox(FamilyRoom.seektrack(5))
FamilyRoom.Disconnect

Secondly, what's the best approach to doing something a little more elegant so that if I hit the volume up button 3 times, I don't have to call the volume up script 3 times each time connecting to the Zoneplayer. I guess I'm asking if there's a ready method for calling the Sonos COM object directly from VB.NET.

Many thanks,
Dave
Osler
HouseBot Guru
Posts: 742
Joined: Fri Feb 03, 2006 11:18 pm

Re: Calling Sonos users

Post by Osler »

Try using the ConnectSynchronously function. It has less overhead and is quicker.

I still am not sure why that error pops up. Try adding a short sleep in between commands to see if that doesn't help (100 ms).

My net version still is not complete.

Osier
Post Reply