It is currently April 20th, 2024, 12:31 pm
How to make nowplaying volume to toggle on/off?
-
- Posts: 29
- Joined: March 23rd, 2017, 7:35 am
How to make nowplaying volume to toggle on/off?
I have toggle button in my new player skin and I want to use it to toggle music player volume on/off, not system volume. Thank you for all your help!
Last edited by Kmafin on March 25th, 2017, 4:32 pm, edited 2 times in total.
-
- Posts: 860
- Joined: August 22nd, 2016, 11:32 pm
- Location: Surrey, B.C., Canada
Re: How to make nowplaying volume to toggle on/off?
Code: Select all
[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying.dll
;Change player type and path, see below for player types
PlayerName=AIMP
PlayerPath="C:\Program Files (x86)\AIMP\AIMP.exe"
PlayerType=Title
Substitute="":"N\A"
MouseScrollUpAction=!CommandMeasure "MeasurePlayer" "SetVolume 100"
MouseScrollDownAction=!CommandMeasure "MeasurePlayer" "SetVolume 0"
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
Deviant Art Page
-
- Rainmeter Sage
- Posts: 16148
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to make nowplaying volume to toggle on/off?
Kmafin, have you found a good solution? Because I'm not sure why is the thread marked as solved (green check).Kmafin wrote:I have toggle button in my new player skin and I want to use it to toggle music player volume on/off, not system volume. Thank you for all your help!
However, if you didn't, CyberTheWorm's solution is good, but it has the disadvantage that it'll toggle between 0% and 100%. There also is a solution to toggle between 0% and the current volume level.
For this you need two variables: Toggle and Volume. Volume represents the actual volume level, while Toggle will be either 0 (when the player is muted), either 1 (otherwise).
A properly created NowPlaying plugin measure can return the volume level ([MeasureVolume] in the following code). The value returned by this measure is used to set the value of the Volume variable, when the volume is changing. This value will be set only if the volume is greater then 0. If it is set to 0, the Volume variable will keep its previous value ("remembering" the volume level). This value will be re-used:
Code: Select all
[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=0,0,0,255
DynamicWindowSize=1
[Variables]
Toggle=1
Volume=0
[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying
PlayerName=WMP
PlayerType=TITLE
[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=ARTIST
[MeasureVolume]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=VOLUME
IfCondition=(MeasureVolume>0)
IfTrueAction=[!SetVariable Toggle "1"][!UpdateMeasure "MeasureToggle"]
OnChangeAction=[!SetVariable Volume "(([MeasureVolume]=0)?#Volume#:[MeasureVolume])"][!UpdateMeasure "MeasureToggle"]
DynamicVariables=1
[MeasureToggle]
Measure=Calc
Formula=( #Volume# * #Toggle# )
OnChangeAction=[!CommandMeasure "MeasurePlayer" "SetVolume [MeasureToggle]"]
IfCondition=(MeasureToggle=0)
IfTrueAction=[!SetOption MeterVolume Text "Mute"][!UpdateMeter "MeterVolume"][!Redraw]
IfFalseAction=[!SetOption MeterVolume Text "Volume: %1%"][!UpdateMeter "MeterVolume"][!Redraw]
DynamicVariables=1
[MeterVolume]
MeasureName=MeasureToggle
Meter=STRING
X=0
Y=0
Padding=15,5,15,5
FontColor=220,220,220
SolidColor=0,0,0,150
FontSize=8
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
DynamicVariables=1
LeftMouseUpAction=[!SetVariable Toggle "(1-#Toggle#)"][!UpdateMeasure "MeasureToggle"]
What you think, does this code looks like what you wanted?
-
- Posts: 29
- Joined: March 23rd, 2017, 7:35 am
Re: How to make nowplaying volume to toggle on/off?
Oh, I didnt know the meaning about "green check". Your solution worked for me as I wanted, just one small problem with it. After I load skin or refresh it, I need to adjust volume level before meter_volume is clickable. When its clickable, then it works flawless. So how can this be fixed? Thank you very much for your help and sorry for late reply.balala wrote:Kmafin, have you found a good solution? Because I'm not sure why is the thread marked as solved (green check).
However, if you didn't, CyberTheWorm's solution is good, but it has the disadvantage that it'll toggle between 0% and 100%. There also is a solution to toggle between 0% and the current volume level.
For this you need two variables: Toggle and Volume. Volume represents the actual volume level, while Toggle will be either 0 (when the player is muted), either 1 (otherwise).
A properly created NowPlaying plugin measure can return the volume level ([MeasureVolume] in the following code). The value returned by this measure is used to set the value of the Volume variable, when the volume is changing. This value will be set only if the volume is greater then 0. If it is set to 0, the Volume variable will keep its previous value ("remembering" the volume level). This value will be re-used:Clicking the meter will mute the player if it's not and will unmute it if it is muted.Code: Select all
[Rainmeter] Update=1000 BackgroundMode=2 SolidColor=0,0,0,255 DynamicWindowSize=1 [Variables] Toggle=1 Volume=0 [MeasurePlayer] Measure=Plugin Plugin=NowPlaying PlayerName=WMP PlayerType=TITLE [MeasureArtist] Measure=Plugin Plugin=NowPlaying PlayerName=[MeasurePlayer] PlayerType=ARTIST [MeasureVolume] Measure=Plugin Plugin=NowPlaying PlayerName=[MeasurePlayer] PlayerType=VOLUME IfCondition=(MeasureVolume>0) IfTrueAction=[!SetVariable Toggle "1"][!UpdateMeasure "MeasureToggle"] OnChangeAction=[!SetVariable Volume "(([MeasureVolume]=0)?#Volume#:[MeasureVolume])"][!UpdateMeasure "MeasureToggle"] DynamicVariables=1 [MeasureToggle] Measure=Calc Formula=( #Volume# * #Toggle# ) OnChangeAction=[!CommandMeasure "MeasurePlayer" "SetVolume [MeasureToggle]"] IfCondition=(MeasureToggle=0) IfTrueAction=[!SetOption MeterVolume Text "Mute"][!UpdateMeter "MeterVolume"][!Redraw] IfFalseAction=[!SetOption MeterVolume Text "Volume: %1%"][!UpdateMeter "MeterVolume"][!Redraw] DynamicVariables=1 [MeterVolume] MeasureName=MeasureToggle Meter=STRING X=0 Y=0 Padding=15,5,15,5 FontColor=220,220,220 SolidColor=0,0,0,150 FontSize=8 FontFace=Segoe UI StringStyle=BOLD StringAlign=LEFT AntiAlias=1 DynamicVariables=1 LeftMouseUpAction=[!SetVariable Toggle "(1-#Toggle#)"][!UpdateMeasure "MeasureToggle"]
What you think, does this code looks like what you wanted?
-
- Rainmeter Sage
- Posts: 16148
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to make nowplaying volume to toggle on/off?
No, I don't think. The meter isn't "clickable" for one update cycle, then it become clickable, even without adjusting the volume level. When you refresh the skin, wait two seconds, then try to click it. Is it clickable? If it's not, have you changed anything in the posted code? If you did, please post the actual code.Kmafin wrote:After I load skin or refresh it, I need to adjust volume level before meter_volume is clickable. When its clickable, then it works flawless. So how can this be fixed?
-
- Posts: 29
- Joined: March 23rd, 2017, 7:35 am
Re: How to make nowplaying volume to toggle on/off?
Ok. I waited couple seconds and still it didn't work. I did small changes, but you can watch yourself. I uploaded the skin and I will send the link for you at private.balala wrote:No, I don't think. The meter isn't "clickable" for one update cycle, then it become clickable, even without adjusting the volume level. When you refresh the skin, wait two seconds, then try to click it. Is it clickable? If it's not, have you changed anything in the posted code? If you did, please post the actual code.
-
- Rainmeter Sage
- Posts: 16148
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: How to make nowplaying volume to toggle on/off?
Usually it's not a good idea to send the link privately, I suppose you should post that link here, too. In fact I don't even see why you wouldn't post it.Kmafin wrote:Ok. I waited couple seconds and still it didn't work. I did small changes, but you can watch yourself. I uploaded the skin and I will send the link for you at private.
Anyway, I have no AIMP installed, so I checked your code with Windows Media Player and have to say I don't have the described issue, it's working perfectly for me. The [METER_VOLUME] meter is clickable from the very first moment.
Now a thing: if you will post the link here, maybe someone who is using AIMP, could test it and could tell us what's the situation. So, please post the link publicly.
Until then, i have to make a few comments about your code:
- Usually the LeftMouseUpAction is the desired option, instead of the LeftMouseDownAction (you've used it eg on the [METER_VOLUME] meter). Here you can find out why.
- The IfCondition on the [MEASURE_TOGGLE] seems useless. Both the IfTrueAction and IfFalseAction options does the same thing: set the Text of the [METER_VOLUME] meter to VOL, update the same [METER_VOLUME] meter and make a redraw. Useless. Instead, remove these options and add the Text=VOL option, to the [METER_VOLUME] meter. In my code the Text of the appropriate meter (in my code that was not the [METER_VOLUME], but the [MeterVolume], but this is not so important, I think) was set differently, depending on the state of the volume, but in your case those IfConditions are useless.
- Never use the [!Update] bang along with the [!Redraw] bang. Again it's useless. The [!Update] bangs updates the whole skin, but in this case a redraw is automatically done. Have to use the [!Redraw] bang only with !UpdateMeter or !UpdateMeterGroup (or eventually with !ShowMeter / !HideMeter / !ShowMeterGroup / !HideMeterGroup), otherwise it's even harmful. Read eg the last paragraph here.
- The !Rainmeter... bang prefix is deprecated. Don't use, just remove it. The !RainmeterPluginBang bang is also deprecated. You should replace it with the !CommandMeasure. Eg replace the LeftMouseUpAction option of the [PROGRESS_01] meter with the following one: LeftMouseUpAction=[!CommandMeasure "Measure_Player[color=#FF0000]" "[/color]SetPosition 1"]. Take care to the extra added quotation marks.
- There's no need to set the Update to Update=100 ([Rainmeter] section). The code doesn't has any reason for a such small Update value. The default Update=1000 would be better, in my opinion.
-
- Posts: 29
- Joined: March 23rd, 2017, 7:35 am
Re: How to make nowplaying volume to toggle on/off?
Obviously I didn't really think... Clearly I have still lot of learning for. I did changes to the skin and it looks pretty good now. I tried WMP and it worked just fine here too. I have animation, that's why its set to 100 (Update). Though I could change it to rotator. If someone wants to test one more time with Aimp, I would be greatful. Download here .rmskin, new upload with the changes: https://www.mediafire.com/?x8k84jb46db2ydebalala wrote:Usually it's not a good idea to send the link privately, I suppose you should post that link here, too. In fact I don't even see why you wouldn't post it.
Anyway, I have no AIMP installed, so I checked your code with Windows Media Player and have to say I don't have the described issue, it's working perfectly for me. The [METER_VOLUME] meter is clickable from the very first moment.
Now a thing: if you will post the link here, maybe someone who is using AIMP, could test it and could tell us what's the situation. So, please post the link publicly.
Until then, i have to make a few comments about your code:
- Usually the LeftMouseUpAction is the desired option, instead of the LeftMouseDownAction (you've used it eg on the [METER_VOLUME] meter). Here you can find out why.
- The IfCondition on the [MEASURE_TOGGLE] seems useless. Both the IfTrueAction and IfFalseAction options does the same thing: set the Text of the [METER_VOLUME] meter to VOL, update the same [METER_VOLUME] meter and make a redraw. Useless. Instead, remove these options and add the Text=VOL option, to the [METER_VOLUME] meter. In my code the Text of the appropriate meter (in my code that was not the [METER_VOLUME], but the [MeterVolume], but this is not so important, I think) was set differently, depending on the state of the volume, but in your case those IfConditions are useless.
- Never use the [!Update] bang along with the [!Redraw] bang. Again it's useless. The [!Update] bangs updates the whole skin, but in this case a redraw is automatically done. Have to use the [!Redraw] bang only with !UpdateMeter or !UpdateMeterGroup (or eventually with !ShowMeter / !HideMeter / !ShowMeterGroup / !HideMeterGroup), otherwise it's even harmful. Read eg the last paragraph here.
- The !Rainmeter... bang prefix is deprecated. Don't use, just remove it. The !RainmeterPluginBang bang is also deprecated. You should replace it with the !CommandMeasure. Eg replace the LeftMouseUpAction option of the [PROGRESS_01] meter with the following one: LeftMouseUpAction=[!CommandMeasure "Measure_Player[color=#FF0000]" "[/color]SetPosition 1"]. Take care to the extra added quotation marks.
- There's no need to set the Update to Update=100 ([Rainmeter] section). The code doesn't has any reason for a such small Update value. The default Update=1000 would be better, in my opinion.
Last edited by Kmafin on March 25th, 2017, 1:46 pm, edited 1 time in total.
-
- Posts: 62
- Joined: February 7th, 2017, 10:02 pm
Re: How to make nowplaying volume to toggle on/off?
I was looking for this code few hours ago when I was creating my own music player skin and I found this one here, on this forum.
Left click and right click usually do other stuff on music player skin so middle click for an instant turn off/on volume would be better, I think :P
but there is a bug here, if you toggle it off and then volume up or down, the next time you toggle volume on/off it will take you to the last volume you checked, I can't really explain it.
But it works perfectly if you toggle it on after you toggle it off.
Code: Select all
MiddleMouseUpAction=[!SetVariable LastVolume "[mVolume]"][!CommandMeasure mPlayer "SetVolume #LastVolume#"]
but there is a bug here, if you toggle it off and then volume up or down, the next time you toggle volume on/off it will take you to the last volume you checked, I can't really explain it.
But it works perfectly if you toggle it on after you toggle it off.
-
- Posts: 29
- Joined: March 23rd, 2017, 7:35 am
Re: How to make nowplaying volume to toggle on/off?
Good coincidence!GioRgSaVv wrote:I was looking for this code few hours ago when I was creating my own music player skin and I found this one here, on this forum.
Left click and right click usually do other stuff on music player skin so middle click for an instant turn off/on volume would be better, I think :PCode: Select all
MiddleMouseUpAction=[!SetVariable LastVolume "[mVolume]"][!CommandMeasure mPlayer "SetVolume #LastVolume#"]
but there is a bug here, if you toggle it off and then volume up or down, the next time you toggle volume on/off it will take you to the last volume you checked, I can't really explain it.
But it works perfectly if you toggle it on after you toggle it off.
Im happy with the current code, but clearly there is several ways to implement this "feature". Thanks anyway for sharing this, it may be useful for others.