Spotify parcially intergrating

Posted on
Fri May 11, 2012 12:10 pm
henkjanvries offline
User avatar
Posts: 108
Joined: May 05, 2012

Spotify parcially intergrating

Hi everyone,

ive had Indigo for a while but since I've got a rfxcom I've seriously got into indigo.

Right now I'm just trying to get a little bit of spotify integration, which is working a bit.

But I'm trying to fill a variable with the state of spotify: playing or paused.

I've think I've got it with a applescript, but I'm getting an error:

ell application "IndigoServer"
exists variable «constant ****kPSP»
--> error number -10001
Result:
error "IndigoServer got an error: Er heeft zich een descriptor type mismatch voorgedaan." number -10001 to item (sorry dutch language)

does anyone know what to do?
here is my code
Code: Select all
----
property spotifystate : ""
----
if spotifystate = "" then
   
   tell application "Spotify"
      if player state is paused then play
      
      set spotifystate to playing
      
      tell application "IndigoServer"
         if not (variable spotifystate exists) then ¬
            make new variable with properties {name:spotifystate, value:playing}
         if playing is not equal to (value of variable spotifystate) then
            set value of variable spotifystate to playing
         else
            tell application "Spotify" to pause
            
            set spotifystate to paused
            
            tell application "IndigoServer"
               if not (variable spotifystate exists) then ¬
                  make new variable with properties {name:spotifystate, value:paused}
               if paused is not equal to (value of variable spotifystate) then
                  set value of variable spotifystate to paused
               end if
            end tell
         end if
      end tell
   end tell
end if



i hope I'm in he right direction. At least the functions for spotify work, it just that i want the value into a variable n indigo

thanks for the help!

HenkJan

Posted on
Fri May 11, 2012 12:50 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Spotify partially intergrating

Actually, I think there are a few logical problems with the script. I think what you're trying to do is toggle the spotify player and make sure that an Indigo variable is updated when you change it. Try this (untested because I don't have the spotify app):

Code: Select all
----
property spotifyStateVariableName : "INDIGOVARIABLENAMEHERE"
----
-- First, toggle the player state and save the new status
-- in a local AppleScript variable called playerState
tell application "Spotify"
    if player state is paused then
        -- Player is paused so we tell it to play
        play
        set playerState to "playing"
    else
        -- Player is playing so we tell it to pause
        pause
        set playerState to "paused"
    end if
end tell

-- Next, tell Indigo to set the variable to the saved playerState
tell application "IndigoServer"
    -- If the variable doesn't exist then create it with the right values, otherwise just update
    if not (variable spotifystate exists) then ¬
        make new variable with properties {name:spotifystate, value:playerState}
    else
        set value of variable spotifystate to playerState
    end if
end tell

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 11, 2012 1:06 pm
henkjanvries offline
User avatar
Posts: 108
Joined: May 05, 2012

Re: Spotify parcially intergrating

the script got a fault

Code: Select all
-- Next, tell Indigo to set the variable to the saved playerState
tell application "IndigoServer"
    -- If the variable doesn't exist then create it with the right values, otherwise just update
    if not (variable spotifystate exists) then ¬
        make new variable with properties {name:spotifystate, value:playerState}
    [b]else[/b]
        set value of variable spotifystate to playerState
    end if
end tell


else should be end or end tell not else

any clue?

Posted on
Fri May 11, 2012 1:10 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Spotify parcially intergrating

Leftover cruft from your original version:

Code: Select all
----
property spotifyStateVariableName : "INDIGOVARIABLENAMEHERE"
----
-- First, toggle the player state and save the new status
-- in a local AppleScript variable called playerState
tell application "Spotify"
    if player state is paused then
        -- Player is paused so we tell it to play
        play
        set playerState to "playing"
    else
        -- Player is playing so we tell it to pause
        pause
        set playerState to "paused"
    end if
end tell

-- Next, tell Indigo to set the variable to the saved playerState
tell application "IndigoServer"
    -- If the variable doesn't exist then create it with the right values, otherwise just update
    if not (variable spotifystate exists) then
        make new variable with properties {name:spotifystate, value:playerState}
    else
        set value of variable spotifystate to playerState
    end if
end tell

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Fri May 11, 2012 1:15 pm
henkjanvries offline
User avatar
Posts: 108
Joined: May 05, 2012

Re: Spotify parcially intergrating

im not sure what your getting at,

but do you mean that i should have a second script that keeps track of the state of spotify and that the indigo script reads that one to toggle the value of the variable?

Posted on
Fri May 11, 2012 4:00 pm
jay (support) offline
Site Admin
User avatar
Posts: 18199
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Spotify parcially intergrating

I corrected the problem with my first post in my second post...

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sat May 12, 2012 2:25 am
henkjanvries offline
User avatar
Posts: 108
Joined: May 05, 2012

Re: Spotify parcially intergrating

i was think to hard.

here is a undressed version that works.

Code: Select all
---
property spotifystate : ""
---
tell application "Spotify"
   if player state is playing then
      pause
      set spotifystate to "paused"
      
   else
      play
      set spotifystate to "playing"
   end if
end tell
tell application "IndigoServer"
   if not (variable "spotifystate" exists) then ¬
      make new variable with properties {name:"spotifystate", value:spotifystate}
   if "spotifystate" is not equal to (value of variable "spotifystate") then
      set value of variable "spotifystate" to spotifystate
   end if
end tell


thanks for help!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests