It is currently May 2nd, 2024, 6:54 am

Only show skin when a song is playing in Spotify

Get help with creating, editing & fixing problems with skins
User avatar
Pierre
Posts: 12
Joined: May 13th, 2011, 3:15 pm

Only show skin when a song is playing in Spotify

Post by Pierre »

Hey,

so I've recently come across a skin that displays the current track playing in Spotify (music streaming program).

My problem is that I want the skin to be hidden by default and only show either when Spotify is running or when a track is actually playing, preferably the latter.

Code: Select all

[MeasureTrack]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Substitute="[Paused]":"","Spotify - ":"","[Stopped]":"", "Spotify":"", "0":""
The string returned seems to be "0" when Spotify isn't running and "Spotify" when no track is playing.

Any help or thought is appreciated and I want to make it clear that I'm not the author of this skin.

Thanks
Pierre
User avatar
Nugget
Posts: 43
Joined: November 1st, 2010, 4:10 am

Re: Only show skin when a song is playing in Spotify

Post by Nugget »

Not an expert in this, but I'll try and help. You're going to want to use IfActions. So, for example:

Code: Select all

[IfPlaying]
IfEqualValue=1 
IfEqualAction=[!RainmeterShowMeter MeasureTrack]

[MeasureTrack]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Hidden=1
Substitute="[Paused]":"","Spotify - ":"","[Stopped]":"", "Spotify":"", "0":""
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Only show skin when a song is playing in Spotify

Post by santa_ryan »

The string returned seems to be "0" when Spotify isn't running and "Spotify" when no track is playing.
Assuming the above is true, the following will work in theory.

Just add this code in the skin anywhere, preferably the top. DO NOT EDIT THE MEASURETRACK, as I do not know if its substituted values serve any function somewhere else in the skin.

Code: Select all

[MeasureIsPlaying]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Substitute="[Paused]":"0","Spotify - ":"","[Stopped]":"0", "Spotify":"0",

[ConvertStringToNumber]
Measure=Calc
Formula=MeasureIsPlaying

[ShowIfPlaying]
Measure=Calc
Formula=ConvertStringToNumber = 0
IfEqualValue=0
IfEqualAction=!RainmeterHideFade
IfAboveValue=0
IfAboveAction=!RainmeterShowFade
DynamicVariables=1
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Pierre
Posts: 12
Joined: May 13th, 2011, 3:15 pm

Re: Only show skin when a song is playing in Spotify

Post by Pierre »

Code: Select all

[MeasureIsPlaying]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Substitute="[Paused]":"0","Spotify - ":"","[Stopped]":"0", "Spotify":"0",

[ConvertStringToNumber]
Measure=Calc
Formula=MeasureIsPlaying

[ShowIfPlaying]
Measure=Calc
Formula=ConvertStringToNumber = 0
IfEqualValue=0
IfEqualAction=!RainmeterHideFade
IfAboveValue=0
IfAboveAction=!RainmeterShowFade
DynamicVariables=1
Thank you for the answer!

However, it seems like the calculation is a bit wrong. The skin fades out and back again regardless if a track is playing or if Spotify is/isn't running.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Only show skin when a song is playing in Spotify

Post by santa_ryan »

Well crap, im in the US and we dont have "Spotify" services here so i cant test it.... :(
Last edited by santa_ryan on May 13th, 2011, 10:40 pm, edited 2 times in total.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Pierre
Posts: 12
Joined: May 13th, 2011, 3:15 pm

Re: Only show skin when a song is playing in Spotify

Post by Pierre »

santa_ryan wrote:Well crap, im in the US and we dont have "Spotify" services here.... :(
Yes, I know, that sucks.

But I think I've figured out that Measure=Calc always returns "0" regardless of what the string is (in text from MeasureTrack). What am I doing wrong?
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Only show skin when a song is playing in Spotify

Post by santa_ryan »

Try the following. I messed up. Any "Text" will get treated as a 0 by a calc, so even if music was playing, it would still be a 0. Now if music is playing its a 0, but if Spotify is paused then its a -1.

Code: Select all

[MeasureIsPlaying]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Substitute="Spotify - ":"","[Paused]":"-1","[Stopped]":"-1", "Spotify":"-1"

[ConvertStringToNumber]
Measure=Calc
Formula=MeasureIsPlaying

[ShowIfPlaying]
Measure=Calc
Formula=ConvertStringToNumber = -1
IfEqualValue=0
IfEqualAction=!RainmeterShowFade
IfAboveValue=0
IfAboveAction=!RainmeterHideFade
DynamicVariables=1
Also, if you dont like the fade just remove the word fade from the 2 bangs.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
Pierre
Posts: 12
Joined: May 13th, 2011, 3:15 pm

Re: Only show skin when a song is playing in Spotify

Post by Pierre »

santa_ryan wrote: Measure=Calc
Formula=ConvertStringToNumber = -1
IfEqualValue=0
IfEqualAction=!RainmeterShowFade
IfAboveValue=0
IfAboveAction=!RainmeterHideFade
DynamicVariables=1
I'm not sure if this is logical, but even if I try:

Code: Select all

Measure=Calc
Formula=ConvertStringToNumber = -1
IfEqualValue=0
IfEqualAction=!RainmeterShowFade
IfEqualValue=-1
IfEqualAction=!RainmeterHideFade
DynamicVariables=1
It doesn't work either so.

Also, neither does the fade-in-fade-out dance upon refreshing anymore.
User avatar
Pierre
Posts: 12
Joined: May 13th, 2011, 3:15 pm

Re: Only show skin when a song is playing in Spotify

Post by Pierre »

So here is my thought on why it doesn't work, however I'm new to all this and haven't played around with it enough to even get a vague understanding of it all.

The string being returned when:

Spotify is running and playing a track is: Spotify - [Artist] - [Track]
Spotify is paused is: Spotify
Spotify isn't running is: 0 (need to refresh to see the 0)

When a measure is taken it is done in regards to its WindowClass, am I right? (at least when Measure=Plugin)

If a measure on a WindowClass fails because the WindowClass isn't running, does it return a value of "0" then? In other words is it still a usable value or is it just a text string?
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: Only show skin when a song is playing in Spotify

Post by santa_ryan »

Lol... my writing proves that im tired... I dont know wth i was thinking

Okay, this should now work. If the plugin fails (0), spotify is paused (0), spotify is stopped (0), or spotify isnt doing anything (0), then it will return a 0, and fire the bang.
If spotify is playing then Spotify - becomes 1, and any text after that becomes 0, which makes 10, and thats above 0 if its converted number. There will be a 2 second delay just to let you know.

Code: Select all

[MeasureIsPlaying]
Measure=Plugin
Plugin=Plugins\WindowMessagePlugin.dll
WindowClass=SpotifyMainWindow
Substitute="Spotify - ":"1","[Paused]":"0","[Stopped]":"0", "Spotify":"0"

[ConvertStringToNumber]
Measure=Calc
Formula=MeasureIsPlaying

[ShowIfPlaying]
Measure=Calc
Formula=ConvertStringToNumber
IfEqualValue=0
IfEqualAction=!RainmeterHideFade
IfAboveValue=0
IfAboveAction=!RainmeterShowFade
DynamicVariables=1
My apologies for posting so many times trying to get this to work... Just wish i could use spotify myself and test it. :/
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.