It is currently April 19th, 2024, 5:31 am

Need help changing image on click :3

Get help with creating, editing & fixing problems with skins
iBooface
Posts: 18
Joined: October 21st, 2018, 2:48 pm

Need help changing image on click :3

Post by iBooface »

Hi all!

I'm new on rainmeter and i try to create my own buttons to control spotify (playpause/previous/next ) because there are a lot of players but a lot are complicated and too sofisticate for my actual theme, that's why i try to create a simple 3 buttons player :D .

But here is my problem: i tried to change the image of the play/pause button everytime i click so it would be coherent with the music. I tried to google it and then i tried the "!SetOption" methode, and i also tried to set a variable named Num, wich will be used to make a loop with the two images named "Play#Num#", but i failed again ! O.O :jawdrop

That's why i'm here to get help for this simple thing :rofl:

Here is my code:

Code: Select all

[Rainmeter]
Update=1000

[ReWall]
Meter=Image
ImageName=Play.png
W=30
H=30
Tile=0
PreserveAspectRatio=1
LeftMouseDownAction=[!CommandMeasure "Player" "PlayPause"]

[Player]
Measure=Plugin
Plugin=NowPlaying
PlayerType=Artist
PlayerName=Spotify
LeftMouseDownAction=[!CommandMeasure "Player" "PlayPause"]
Thank you for your help !
PS: sry for my english i'm a poor french guy :bow:
Last edited by balala on October 21st, 2018, 3:24 pm, edited 1 time in total.
Reason: Please use code tags when posting code.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

Re: Need help changing image on click :3

Post by kyriakos876 »

iBooface wrote: October 21st, 2018, 3:09 pm Hi all!

I'm new on rainmeter and i try to create my own buttons to control spotify (playpause/previous/next ) because there are a lot of players but a lot are complicated and too sofisticate for my actual theme, that's why i try to create a simple 3 buttons player :D .

But here is my problem: i tried to change the image of the play/pause button everytime i click so it would be coherent with the music. I tried to google it and then i tried the "!SetOption" methode, and i also tried to set a variable named Num, wich will be used to make a loop with the two images named "Play#Num#", but i failed again ! O.O :jawdrop

That's why i'm here to get help for this simple thing :rofl:

Here is my code:

Code: Select all

[Rainmeter]
Update=1000

[ReWall]
Meter=Image
ImageName=Play.png
W=30
H=30
Tile=0
PreserveAspectRatio=1
LeftMouseDownAction=[!CommandMeasure "Player" "PlayPause"]

[Player]
Measure=Plugin
Plugin=NowPlaying
PlayerType=Artist
PlayerName=Spotify
LeftMouseDownAction=[!CommandMeasure "Player" "PlayPause"]
Thank you for your help !
PS: sry for my english i'm a poor french guy :bow:
I don't really use this plugin/measure but try this:

Code: Select all

[Rainmeter]
Update=1000

[MeasureState]
Measure=NowPlaying
PlayerType=State
Substitute="0":"Play","1":"Pause","2":"Play"
DynamicVariables=1
OnChangeAction=[!UpdateMeter ReWall][!Redraw]

[ReWall]
Meter=Image
ImageName=[MeasureState].png
W=30
H=30
Tile=0
PreserveAspectRatio=1
LeftMouseDownAction=[!CommandMeasure "Player" "PlayPause"]
DynamicVariables=1
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help changing image on click :3

Post by balala »

The rewritten code:

Code: Select all

[Rainmeter]
Update=1000

[ReWall]
Meter=Image
W=30
H=30
Tile=0
PreserveAspectRatio=1
LeftMouseUpAction=[!CommandMeasure "Player" "PlayPause"]

[Player]
Measure=NowPlaying
PlayerType=Artist
PlayerName=Spotify

[MeasureState]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=State
IfCondition=(#CURRENTSECTION#=1)
IfTrueAction=[!SetOption ReWall ImageName "Pause.png"][!UpdateMeter "ReWall"][!Redraw]
IfFalseAction=[!SetOption ReWall ImageName "Play.png"][!UpdateMeter "ReWall"][!Redraw]
Note the following: the [MeasureState] measure returns 0 if the player is stopped, 1 if it's playing, and 2 if it's paused. Accordingly, in second case (so, when the measure returns 1) the image of [ReWall] meter is set to Pause.png, otherwise it is set to Play.png. The image is following the state of player, so the appropriate image is set, no mater if you stop / pause the player through the skin , or by clicking the button of the player itself.

EDIT: kyriakos876 beat me. His code is another solution to the same question.
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help changing image on click :3

Post by balala »

Let's note three more details:
  • LeftMouseDownAction (and same way nor LeftMouseUpAction) is not a valid option on measures, just on meter. You've used it on the [Player] measure. I removed it.
  • Instead of LeftMouseDownAction, LeftMouseUpAction would be preferred. Here you can find out why: https://docs.rainmeter.net/manual-beta/mouse-actions/#LeftMouseUpAction
  • Although a while ago NowPlaying was a plugin, i the meantime it became a measure and should have to be used accordingly.
My code posted above respects all these observations.
iBooface
Posts: 18
Joined: October 21st, 2018, 2:48 pm

Re: Need help changing image on click :3

Post by iBooface »

Ok thank you i take notes and i think i got it ! Next time i'll be okay with this i think xD !
I'll try this in a minute! :D

Thank you again !
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help changing image on click :3

Post by balala »

iBooface wrote: October 21st, 2018, 6:34 pm I'll try this in a minute! :D
Ok, let me know if you got it working.
iBooface
Posts: 18
Joined: October 21st, 2018, 2:48 pm

Re: Need help changing image on click :3

Post by iBooface »

OK it work i'm gonna add if i can a blur sort of fadding effect between the images....

But there is a new problem: my rainmeter started to be laggy like... I've got 4 soundbars wich were working before i chagned the code of my button, but now they are laggy , they move with like 3fps :? Maybe rainmeter is overloaded because i use a lot of skin together (i'm using a saved layout, and i removed all the skins that i don't use )

if you want i can give you a screenshot but i ve got 2 images that i don't own and i m waiting for the artist to give me the permission to use those two images so i'll have to blur it
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help changing image on click :3

Post by balala »

iBooface wrote: October 21st, 2018, 6:49 pm i'm gonna add if i can a blur sort of fadding effect between the images....
Not impossible, but nor easy is. I'm not sure it worth...
iBooface wrote: October 21st, 2018, 6:49 pm I've got 4 soundbars wich were working before
What those four soundbars are? Some visualizer skin?
iBooface
Posts: 18
Joined: October 21st, 2018, 2:48 pm

Re: Need help changing image on click :3

Post by iBooface »

yes this is a basic visualizer wich propose soomething interessant: you can clone your setup, and that's what i did to get 4 small visualizer , i think i can mp you a screen

maybe i should give more ram to rainmeter...
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Need help changing image on click :3

Post by balala »

iBooface wrote: October 21st, 2018, 7:16 pm yes this is a basic visualizer wich propose soomething interessant: you can clone your setup, and that's what i did to get 4 small visualizer , i think i can mp you a screen
4 times practically the same visualizer skin? This explains why that lagging goes on. A visualizer skin from start has a low Update value (within the [Rainmeter] section). This is needed by the skin, to can quickly react. Loading four such skins at a time definitely makes Rainmeter to be laggy. Don't expect it to be different...
iBooface wrote: October 21st, 2018, 7:16 pm maybe i should give more ram to rainmeter...
I would be curious how can you do this?