Announcement

Collapse
No announcement yet.

Getting Track #, Track Count and Music Source

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Getting Track #, Track Count and Music Source

    Hi,

    Am happily extracting track and album related info from the plugin.
    I'm also keen to get:
    1. The Current Track Number (i.e. Track 5)
    2. The Number of Tracks in the Album (i.e. 11) and the Playlist (i.e. 423)
    3. The Music Source (i.e. Music Library/Amazon/pandora/SiriusXM etc..)

    How might I accomplish this?

    Thanks.

    #2
    Originally posted by skavan View Post
    Hi,

    Am happily extracting track and album related info from the plugin.
    I'm also keen to get:
    1. The Current Track Number (i.e. Track 5)
    2. The Number of Tracks in the Album (i.e. 11) and the Playlist (i.e. 423)
    3. The Music Source (i.e. Music Library/Amazon/pandora/SiriusXM etc..)

    How might I accomplish this?

    Thanks.
    If the MediaAPI will ever get implemented properly, you would have some of that info. There is no other easy way unless you are very familiar with programming that you can import the plugin API into Visual Studio and you'll find most of that information available in public variables.

    Dirk

    Comment


      #3
      Thanks.
      I did look at the plugin API in VS and it looks promising...but am stuck at how to access the objects within a script.
      If I create a new HSPI object, it's just that - new - and doesn't reflect the "live object". Would you mind kicking me in the right direction on how to access the live HSPI object?

      Thanks.

      Comment


        #4
        Originally posted by skavan View Post
        Thanks.
        I did look at the plugin API in VS and it looks promising...but am stuck at how to access the objects within a script.
        If I create a new HSPI object, it's just that - new - and doesn't reflect the "live object". Would you mind kicking me in the right direction on how to access the live HSPI object?

        Thanks.
        I'm currently on the road so I don't have access to any of my systems but if you found the right methods to call, search this forum under the scripting part how to call these methods directly from your script. I'm not sure what you mean by "life" objects but obviously my PI doesn't know how to call your script nor does it generate events so the only way to make this more "alive" is to create events based on lets say track change, add an action to call you script and in the script to call the right properties or methods to get more info. Do note however, and maybe this is why you experience "not alive object", that this PI is a SingleEXEMultipleInstance PI. It means it has multiple instances of the class HSPI. If you search this board, you'll find the right syntax as to how to call the right instance. It is by using PI name (Sonos) and right Instance name, the latter is the UDN (RINCON_XXXXXXXXX) of the player which you can find when you click on "manage plugins".

        Hope this helps

        Dirk

        Comment


          #5
          Thanks.
          I dug into this and have managed to extract the Current Track Number:
          (GetTrackInfo - element 7)
          and the number of tracks:
          (TracksInQueue).

          I am stuck on a couple of items:
          1. Current Music Source (i.e. Music Library/Pandora/Sirius XM etc..).
          I could deduce this from the TrackURI that is delivered by uPnP in AV transport.
          For example, the Amazon source is preficed with x-sonos-http:amz, the Pandora source is prefixed with pndrradio etc..But I can't find anywhere in the plugin where this exposed.

          2. AlbumArt for sources not supported in the plugin.
          For example, in TrackMetaData the url to Pandora Artwork is:
          <upnp:albumArtURI>http://cont-sjl-pandora.com/images/public/rovi/albumart/3/2/1/9/074646939123_500W_500H.jpg</upnp:albumArtURI>. For sources like Amazon, this would allow me to point to the Artwork...but again, I can't figure out how to access this data element.

          My challenge is I can't figure out how to access these elements. Any ideas?
          Attached are some screenshots of my work in progress. you will not that the music source is indeterminate and the amazon cover art is missing.

          Thanks.
          Attached Files
          Last edited by skavan; October 26, 2015, 01:08 AM.

          Comment


            #6
            Originally posted by skavan View Post
            Thanks.
            I dug into this and have managed to extract the Current Track Number:
            (GetTrackInfo - element 7)
            and the number of tracks:
            (TracksInQueue).

            I am stuck on a couple of items:
            1. Current Music Source (i.e. Music Library/Pandora/Sirius XM etc..).
            I could deduce this from the TrackURI that is delivered by uPnP in AV transport.
            For example, the Amazon source is preficed with x-sonos-http:amz, the Pandora source is prefixed with pndrradio etc..But I can't find anywhere in the plugin where this exposed.

            2. AlbumArt for sources not supported in the plugin.
            For example, in TrackMetaData the url to Pandora Artwork is:
            <upnp:albumArtURI>http://cont-sjl-pandora.com/images/public/rovi/albumart/3/2/1/9/074646939123_500W_500H.jpg</upnp:albumArtURI>. For sources like Amazon, this would allow me to point to the Artwork...but again, I can't figure out how to access this data element.

            My challenge is I can't figure out how to access these elements. Any ideas?
            Attached are some screenshots of my work in progress. you will not that the music source is indeterminate and the amazon cover art is missing.

            Thanks.
            I'm currently out of the country on travel so I can't help you right now. However for the art you should use the HS device that I created for that because if the art doesn't show up in that device, you are almost 100% guaranteed that it is not accessible for one or another reason.

            For the source, i know I store (what I think I derived from the URI) it in a variable somewhere, check for all properties or simple functions. Just a note of caution, Sonos doesn't have a concept of source, I just by trial and error over the years have derived it from how they structure their URI.

            So here is my personal advice, keep it simple. It is personal preference what you would like to see on your screens and a lot of us are into creating really great awesome things. The issue is that Sonos has NO commitment what so ever with any of its developers when it comes to the UPNP interface that is being used. So whatever works today, might not work tomorrow ... or as Sonos adds support for other services, what works for one service might not work for other services. So in our strive for perfection, things might get more frustrating rather than enjoyable when half of the stuff works and the other doesn't. When I started nearly 5 years ago, I spent a lot of time on my HSTouch screens to realize after so many years that the only thing I would use it for is to see what is playing, perhaps start/pause but that was as far as it went. Even browsing content in HS2 was slow and awkward using up/down errors to scroll. What I'm saying is that the HSTouch interface, especially today, is light years behind in terms of usability as opposed to the native apps in mobile devices where you can swipe, pinch/expand etc. and are always 100% up to date with what Sonos supports. I now actually use my old (retired) iPhone as controllers and leave them lying around when I have guests.

            Anyway, as I said, it is all about personal preference, a good chunk is about the challenge, good luck and I'll be happy to support you as best as I can when I get back stateside.

            Dirk

            Comment


              #7
              Totally aligned with all your thoughts!
              I am not using HSTouch at all for the reasons you describe.
              At the client end, I am using iRule (http://getirule.com/) and interfacing to Homeseer through tcpip (drhslpPlugin).
              On the client-side, iRule allows one to leap to other Android or IOS apps, so am using the native Sonos App for detail control of my Sonos...
              What i am trying to do is create a fairly modest status page on the tablet GUI with rudimentary control (play, pause, next, previous etc..). That's what you see in the images above.

              Now onto the quest to find the music source property! You do indeed have one in your plugin, but it doesn't return anything!

              Rather than do a hs.PluginFunction or PluginPropertyget on every single property/function, I am wondering of there is a way to access the Sonos HSPI object itself (and I can then inspect the properties in the Visual Studio API using tenscripting3).

              I have tried using GetSonosPlayerByUDN but it returns nothing. Any Ideas?
              I get the UDN in the first line below (which works, and of course is the same RINCONxxx anyway)! But the second call returns nothing!
              Code:
              Dim UDN As String = hs.PluginFunction("Sonos", "RINCON_000E58A72F9601400", "GetUDN", Nothing)
              Dim obj2 As HSPI_Sonos.HSPI = hs.PluginFunction("Sonos", "RINCON_000E58A72F9601400", "GetSonosPlayerByUDN", New Object() {UDN})
              Thanks for all your help!

              Comment


                #8
                Originally posted by skavan View Post
                Totally aligned with all your thoughts!
                I am not using HSTouch at all for the reasons you describe.
                At the client end, I am using iRule (http://getirule.com/) and interfacing to Homeseer through tcpip (drhslpPlugin).
                On the client-side, iRule allows one to leap to other Android or IOS apps, so am using the native Sonos App for detail control of my Sonos...
                What i am trying to do is create a fairly modest status page on the tablet GUI with rudimentary control (play, pause, next, previous etc..). That's what you see in the images above.

                Now onto the quest to find the music source property! You do indeed have one in your plugin, but it doesn't return anything!

                Rather than do a hs.PluginFunction or PluginPropertyget on every single property/function, I am wondering of there is a way to access the Sonos HSPI object itself (and I can then inspect the properties in the Visual Studio API using tenscripting3).

                I have tried using GetSonosPlayerByUDN but it returns nothing. Any Ideas?
                I get the UDN in the first line below (which works, and of course is the same RINCONxxx anyway)! But the second call returns nothing!
                Code:
                Dim UDN As String = hs.PluginFunction("Sonos", "RINCON_000E58A72F9601400", "GetUDN", Nothing)
                Dim obj2 As HSPI_Sonos.HSPI = hs.PluginFunction("Sonos", "RINCON_000E58A72F9601400", "GetSonosPlayerByUDN", New Object() {UDN})
                Thanks for all your help!
                In HS2 you could get a handle/pointer to a MusicAPI because HS2 and all PI ran as one big executable. Getting a handle in HS3 is useless, all PI are exe running by themselves, they can even be running on a different PC. So you MUST call all functions through the HS3 provided interface which is something like:

                hs.PluginFunction("PluginName", "InstanceName", "FunctionName", Parameters)

                there is no other way around it.

                So back to your other question on HSPI, it is a class of which the Sonos executable created multiple instances. There is one instance which actually has an empty name (hs.PluginFunction("Sonos", "", "functionxyz", Parameterxyz), this is sort of the root/master of the PI. It controls zero state of ANY player, it holds all the actions you typically do ACROSS players, such as linking, announcements etc. So if you call this instance for things like track name etc, it will return empty info because it doesn't control any. For example getUDN would only work on the "root" HSPI instance because the root "sees" all the instances of all the players. Then there is an HSPI instance for EACH player which you can reach by using the UDN names , an these object do hold info like track info etc. One player doesn't know anything about other players.

                I know it is a bit confusing but the PI wasn't written for people to go muck around in, that's also why I did not publish any API info for the HS3 version. I trust you understand. The right way to get access was through the MediaAPI but those functions are not working at this point as HS3 doesn't seem to call the right instances themselves.

                When I get back home I can dig up which functions you can call that might give you the right info you are looking for.

                Dirk

                Comment


                  #9
                  Makes perfect sense. Thanks.
                  I will wait until you get home!
                  The two elements I am looking to get are:
                  1. MusicSource (which you have created by detective work from the TrackURI) and
                  2. TrackMetaData (which contains an xml link to the Amazon Player's Track Art which is the one service where your plugin doesn't seem to pull the artwork, probably because its in yet another format!)

                  I built my own UPnP service a year or two ago (not for homeseer) and it was nightmare between the quirks of upnp.dll, intels version, and Sonos's wild inconsistencies in how they treat differing services. Your plugin does an absolutely amazing job.

                  When you put it in the store, I will be at the top of the line to BUY it!

                  Comment


                    #10
                    Originally posted by skavan View Post
                    Makes perfect sense. Thanks.
                    I will wait until you get home!
                    The two elements I am looking to get are:
                    1. MusicSource (which you have created by detective work from the TrackURI) and
                    2. TrackMetaData (which contains an xml link to the Amazon Player's Track Art which is the one service where your plugin doesn't seem to pull the artwork, probably because its in yet another format!)

                    I built my own UPnP service a year or two ago (not for homeseer) and it was nightmare between the quirks of upnp.dll, intels version, and Sonos's wild inconsistencies in how they treat differing services. Your plugin does an absolutely amazing job.

                    When you put it in the store, I will be at the top of the line to BUY it!
                    just checking if you have returned and would be able to shed light on the above as per prior discussion. Thx.

                    Comment


                      #11
                      Originally posted by skavan View Post
                      just checking if you have returned and would be able to shed light on the above as per prior discussion. Thx.
                      Back stateside as of last night. This weekend out of town.
                      Will look at it this Monday. Thanks for reminding me.

                      Dirk

                      Comment


                        #12
                        Originally posted by skavan View Post
                        Makes perfect sense. Thanks.
                        I will wait until you get home!
                        The two elements I am looking to get are:
                        1. MusicSource (which you have created by detective work from the TrackURI) and
                        2. TrackMetaData (which contains an xml link to the Amazon Player's Track Art which is the one service where your plugin doesn't seem to pull the artwork, probably because its in yet another format!)

                        I built my own UPnP service a year or two ago (not for homeseer) and it was nightmare between the quirks of upnp.dll, intels version, and Sonos's wild inconsistencies in how they treat differing services. Your plugin does an absolutely amazing job.

                        When you put it in the store, I will be at the top of the line to BUY it!
                        Hi Skavan,

                        looked at my code, unfortunately, neither of them is available publicly. Which version of the PI are you using (R3.0.x.x or R3.1.x.x)? I can change it and post a beta here if that helps.

                        Dirk

                        Comment


                          #13
                          3.0 (what is 3.1)?
                          I will send you a PM with various thoughts as it's too heavy for the forum!

                          s.

                          Comment


                            #14
                            Originally posted by skavan View Post
                            3.0 (what is 3.1)?
                            I will send you a PM with various thoughts as it's too heavy for the forum!

                            s.
                            After you upgraded via the updater (beta section) to v3.1.x.x download the attached, unzip and overwrite the .exe in the <HS3 root directory>

                            Please reply here when downloaded so I'll remove it again

                            Dirk
                            Last edited by dcorsus; November 18, 2015, 05:23 PM.

                            Comment


                              #15
                              Originally posted by dcorsus View Post
                              After you upgraded via the updater (beta section) to v3.1.x.x download the attached, unzip and overwrite the .exe in the <HS3 root directory>

                              Please reply here when downloaded so I'll remove it again

                              Dirk
                              Added properties
                              - ZoneIPAddress as String
                              - ZoneMACAddress as String
                              - ZoneThirdPartyMediaServices as string

                              Added Methods
                              - GetHouseHoldID returns string
                              - Public Function ListAvailableServices(ByRef AvailableServiceDescriptorList As String, ByRef AvailableServiceTypeList As String, ByRef AvailableServiceListVersion As String) As String (returns empty or OK, all parameters are by REFERENCE)

                              Dirk
                              Last edited by dcorsus; November 18, 2015, 09:44 PM.

                              Comment

                              Working...
                              X