Announcement

Collapse
No announcement yet.

SpotSeer: A Spotify plugin for HomeSeer

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    SpotSeer: A Spotify plugin for HomeSeer

    BETA: SpotSeer - A Spotify client for HomeSeer
    This plugin will allow you to control play music via Spotify and your HomeSeer servers soundcard. It is a very simple plugin, but should be able to do the job just fine. For more advanced uses, multi zone setups, etc, I refer you to the excellent (or so I hear) Squeezebox plugin.

    SpotSeer creates three devices. The first for artist and track information together with Play/Pause, Next and Previous controls. The two next devices are for selecting playlists and tracks respectively.



    At the moment there is no track and playlist management via the plugin, you do all that from the original Spotify application(s). However, I'm planning to implement a simple search routine (it's nearly done).

    It also supports various scripting functions:
    Code:
    hs.Plugin("SpotSeer").Spotify.Play()
    Start playing if a track is loaded or paused
    
    hs.Plugin("SpotSeer").Spotify.Pause()
    Pauses if a track is playing.
    
    hs.Plugin("SpotSeer").Spotify.PlayPause()
    Toggles play/pause.
    
    hs.Plugin("SpotSeer").Spotify.PlayPrevious()
    Plays the previous track in the playlist.
    
    hs.Plugin("SpotSeer").Spotify.PlayNext()
    Plays the next track in the playlist.
    
    hs.Plugin("SpotSeer").Spotify.PlayAt(index)
    Start playing the track at a specific place in the playlist.
    
    hs.Plugin("SpotSeer").Spotify.LoadPlaylist(index_or_hash)
    Loads a playlist specified either by index or by hash (like "5773521").
    
    hs.Plugin("SpotSeer").Spotify.LoadPlaylistFromString(playlist_name)
    Loads a playlist specified by the playlistname (like "My Foo Fighters playlist").
    
    hs.Plugin("SpotSeer").Spotify.RefreshPlaylists()
    Refreshes the playlists.
    
    hs.Plugin("SpotSeer").Spotify.RefreshTracks()
    Refreshes the tracks.

    SpotSeer also works great with HStouch, just use list boxes like you normally would for a device with device values. However, after alot of programming and swearing to make it work and refresh like you would expect it to (like refresh the track list when you select a new playlist) I discovered that there's a bug in HStouch. So... I'm not causing it, HStouch is.

    Annoying? Yes it is. But perhaps it will be resolved soon, the more that complains the faster it gets fixed.



    Changelog:
    0.5.0
    Completely redesigned the whole plugin.

    0.0.1
    The old version, see the post below.

    Known issues:
    HStouch can't refresh the lists of playlists and tracks. The /stat page works great (after you refresh the page manually).
    This is BETA, there has to be bugs.
    If you're upgrading, delete the existing SpotSeer device and hspi_spotseer.ini in the /Config folder.
    Attached Files
    Last edited by Moskus; July 8, 2011, 02:02 PM.
    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
    Running on Windows 10 (64) virtualized
    on ESXi (Fujitsu Primergy TX150 S8).
    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

    #2
    This is the description of the old version (0.0.1)...

    It has been discussed earlier, and somebody had to do something about the missing spotify plugin issue.
    So I started working on it, and found more problems than solutions. The issues are:

    ... and these issues results in some rather huge limitations like:
    • I had to build my own playlist handler, so you can't access the playlist you already have (waiting for the Playlist API)
    • You need to install Spotify on your HS machine (waiting for the .NET wrapper to work)
    • There's a 1 second gap (but this is user adjustable) between tracks in the playlist and that gap let's Spotify continue on the next track on the album for 1 second instead of continuing on the playlist right away (waiting for Spotify to fix the /uri option)
    • The user inteface is not the prettiest (waiting on me to implement the Music API and/or someone other than me to create a decent webpage).



    BUT:
    • IT DOES THE TRICK!


    Here you go!
    1. Download the zip-file
    2. Stop HomeSeer
    3. Copy the DLL in the zip to your HomeSeer directory
    4. Start HomeSeer again
    5. Go to Setup -> Interfaces and enable "SpotSeer". Remember to save!
    6. Done! You can now navigate to the SpotSeer page (\SpotSeer)
    7. Search and create the playlists you want (the playlists are stored in the \Config folder as xml-files)


    And remember, this is very far from perfect. But it lets me control Spotify from HomeSeer and HStouch.
    Last edited by Moskus; July 8, 2011, 11:45 AM.
    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
    Running on Windows 10 (64) virtualized
    on ESXi (Fujitsu Primergy TX150 S8).
    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

    Comment


      #3
      (right blank?)
      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
      Running on Windows 10 (64) virtualized
      on ESXi (Fujitsu Primergy TX150 S8).
      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

      Comment


        #4
        Moskus...thanks for this, Spotify is something I used last year and it will be a nice addition to my HS setup.

        I've installed it, all looks fine until I come to play something - it selects, adds to the playlist but it won't play. If I view the spotify window the track is actually selected and highlighted but does not play.

        Is it something i'm doing wrong?

        Comment


          #5
          No, you are not doing anything wrong. But Spotify is.

          This happens because Spotify changed the behaviour of the /uri startup argument. So what I do now is wait 1000 ms to let Spotify open and select the track, and then I send an "Enter" command (as in the keypress -> "Start playing now!").


          What you can do is to open the Options page and increase the "Enter delay" (second option from the top) from 1000 to... say.... 1500 (that's a second and a half). If that doesn't work I have no other suggestion than to try 2000 milliseconds.

          Please report back if it works or not.


          And at first run, Spotify can be a little slow. So it will go smoother over time, and then perhaps you can decrease the Enter Delay. I have it running prety smooth on 700 ms now. But I'm hoping to avoid this stupid hack completely. I've contacted Spotify on GetSatisfaction, and I've sent them an email (spotifys email support is rather good) on friday, so hopefully I get an "official" answer next week.
          HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
          Running on Windows 10 (64) virtualized
          on ESXi (Fujitsu Primergy TX150 S8).
          WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

          Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

          Comment


            #6
            OK thanks, i've increased it to 2000ms and still nothing - although if I load it up and hit enter manually it works. I'll give it a restart to see if that helps anything...

            Does it matter that i'm using the free edition? The main Spotify window says 'Spotify Free' which I know that hs.keys needs the title of the app, not sure if that presents a problem or not?

            Comment


              #7
              Originally posted by mrhappy View Post
              Does it matter that i'm using the free edition? The main Spotify window says 'Spotify Free' which I know that hs.keys needs the title of the app, not sure if that presents a problem or not?
              I've only tested this with "Spotify Premium", but the plugin doesn't search for the Main Window Handle using the Window Title, it uses the process name. If this doesn't work I'll get the process by using the executable name (spotify.exe), but searching for the Window name is normally faster so I'm a little reluctant to switch.


              If you manually start playing, can you control Spotify using the "Play/Pause" button on the SpotSeer Device?
              HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
              Running on Windows 10 (64) virtualized
              on ESXi (Fujitsu Primergy TX150 S8).
              WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

              Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

              Comment


                #8
                No they don't work either i'm afraid, the device stays with the string unknown and the buttons do not respond.

                It may just be my setup - i'll restart and play around to see if I can get it to work, Task Manager/What's Running both report the process name as spotify.exe if thats any help.

                If not it may give me an excuse to upgrade to premium!

                Comment


                  #9
                  Originally posted by mrhappy View Post
                  No they don't work either i'm afraid, the device stays with the string unknown and the buttons do not respond.

                  It may just be my setup - i'll restart and play around to see if I can get it to work, Task Manager/What's Running both report the process name as spotify.exe if thats any help.

                  If not it may give me an excuse to upgrade to premium!
                  My plugin is based on "Spotify-O-Matic" , and I've added some more code as the wrapper is not enought to do what I want.

                  The "Window" the plugin is looking for is "SpotifyMainWindow" and I don't believe that is depending on the account type...
                  HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                  Running on Windows 10 (64) virtualized
                  on ESXi (Fujitsu Primergy TX150 S8).
                  WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                  Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                  Comment


                    #10
                    OK, now when Spotify was logged in on my Server, I had to hit Play on a track 4 times before Spotify started playing...

                    MrHappy, if you still can't get it to work after a restart, I have another version here that gets the MainWindowHandle from the actual process called "spotify", it's not using the FindWindow API.
                    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                    Running on Windows 10 (64) virtualized
                    on ESXi (Fujitsu Primergy TX150 S8).
                    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                    Comment


                      #11
                      Moskus...it looks like its working fine now after a restart thanks (should've tried that first sorry) - this is a fantastic plugin!

                      Whats the rule with spotify running? I'm sure when I first loaded it i'm sure the plugin launched spotify for me, but i've just tried it from startup and get;

                      19/09/2010 19:19:20 - SpotSeer Error - An unexpected error occured in the PagePut() function/subroutine: [System.NullReferenceException: Object reference not set to an instance of an object. at HSPI_SPOTSEER.HSPI.PagePut(String lnk)]
                      Launching Spotify manually and then going into the playlist works fine, Should I be putting a launch entry into my startup.vb file?

                      Are you willing to share how you are using it with HSTouch? Are you using embedded HTML pages?

                      Once again thanks...

                      Comment


                        #12
                        Originally posted by mrhappy View Post
                        Moskus...it looks like its working fine now after a restart thanks (should've tried that first sorry) - this is a fantastic plugin!
                        Thanks, I'm glad you like it!

                        Originally posted by mrhappy View Post
                        Whats the rule with spotify running? I'm sure when I first loaded it i'm sure the plugin launched spotify for me, but i've just tried it from startup and get;

                        19/09/2010 19:19:20 - SpotSeer Error - An unexpected error occured in the PagePut() function/subroutine: [System.NullReferenceException: Object reference not set to an instance of an object. at HSPI_SPOTSEER.HSPI.PagePut(String lnk)]

                        Launching Spotify manually and then going into the playlist works fine, Should I be putting a launch entry into my startup.vb file?
                        The plugin is not depending on Spotify at all. It just uses it as a "standalone player".

                        Therefore, you should not need to put anything in startuptxt. But you might recheck that the path to Spotify is correctly detected by the plugin. It assumes that you have spotify running in the default location, which is:
                        C:\"Your 32 bit program folder"\Spotify\Spotify.exe
                        (like c:\program files\spotify\spotify.exe)

                        However, if it works after that it really should'nt be a problem.


                        Plainly put, the plugin is really stupid. It is really just a 3. party playlist manager. It uses the Metadata API and puts the result into my own class of tracks. This class also stores the Track HREF which, when you press play or the plugin advances to the next track, is used to play the track with a startup argument. So say you have the track "Let it Die" by Foo Fighers in your playlist. When it's time to play it, the plugin just starts Spotify like this:

                        Code:
                        Spotify.exe /uri spotify:track:4sWk6tbgVPkA8OAk0utIz3
                        Very simple. But it works.

                        Playlists are stored in XML-format. Just navigate to the \Config folder and find a playlist-xml file and open it. Then you'll see what I do.


                        I don't really understand the error. The PagePut sub is really simple, nothing should go wrong there... but I'll look into it.

                        Originally posted by mrhappy View Post
                        Are you willing to share how you are using it with HSTouch? Are you using embedded HTML pages?
                        Yes. I just embed the HTML page.
                        (And of course make buttons for Play/Pause, Next and Previous).


                        The idea was to do something clever with the Music API or any other way to make the Spotify plugin behave like the Windows Media Player plugin (you know, with the track selector and everything).

                        But I had so many problems with just getting Spotify to do what I want. I've wasted MANY hours getting libspotify and the .NET wrapper to work. I was NOT happy when it turned out I had to abandon that plan (but that's just for now, when the .NET wrapper is stable you can expect a whole new plugin).

                        I haven't had the time to look deeply into the Music API yet. I just noticed that many of the functions of the Music API would be very hard to implement in the Spotify plugin in it's current state.

                        And then I thought it was rather simple to create a aspx page. But it turns out it's not. At least not for me, I'm a asp.net "noob".
                        HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                        Running on Windows 10 (64) virtualized
                        on ESXi (Fujitsu Primergy TX150 S8).
                        WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                        Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                        Comment


                          #13
                          Thanks for the info, nice to know how things work and looking forward to when the wrapper is more stable..

                          I'm going to see how far I can get with HSTouch. I'm just thinking for my house shutdown event is there any way just to stop the player if it is or isnt playing? I suppose I could check the device string to see if it was equal to the 'Not playing' string but just wondering if there is an easier way?

                          Thanks

                          Comment


                            #14
                            I'll see what I can do. It's not as easy as you would expect, but hopefully I can add commands for just "Play" and "Pause.
                            HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                            Running on Windows 10 (64) virtualized
                            on ESXi (Fujitsu Primergy TX150 S8).
                            WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                            Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                            Comment


                              #15
                              ... and if any americans wonder why they don't have Spotify yet, they can tell it to Apple.

                              http://news.cnet.com/8301-31001_3-20018971-261.html
                              HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                              Running on Windows 10 (64) virtualized
                              on ESXi (Fujitsu Primergy TX150 S8).
                              WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                              Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                              Comment

                              Working...
                              X