Aryx wrote: ↑January 9th, 2024, 11:04 am
1) No, I did not succeed in making a skin capable of changing the variables automatically - without human intervention.
2) That said, I am in no rush. I have another idea - that uses your bang way (what a banger
![ROLMFAO :rolmfao:](./images/smilies/bj.gif)
)
3) Using the above in same way you used in your latest post. Also, is bang0 correctly written? Is it empty? What is its function?
4) Weird bug (Unrelated to the post)
Aryx wrote: ↑January 9th, 2024, 11:48 am
5) So, is there any room for improvement in this?
3) Yes,
Bang0=[] is the empty bang (
[]) and is correctly written. It basically does nothing. Alternatively, I guess you could declare it like
Bang0=. I chose the square bracket form to make it clear that it's used as a bang, that's all.
As promised, 1), 2) and 5) led to the below, which I think functions correctly and is as light as it should be on the CPU (for my Winamp at least - not sure what the "bug" at 4) or your other experiments could be about since I don't use AIMP and didn't try them):
Code: Select all
[Variables]
PlayerName=WINAMP
FontName=Consolas
FontSize=11
FontColorN=0,0,0,55
FontColor=255,255,255,255
PreSym=⏪
PreText=Previously
CurrSym=🎵
CurrText=Now Playing
NextSym=⏩
NextText=Coming Up
Track=[Title] - [Artist] - [Album]
BangIndex=1
Bang0=[]
Bang1=[!SetVariable BangIndex 0][!CommandMeasure Player "Previous"][!UpdateMeasure *][!SetVariable Prev "[*Track*]"][!CommandMeasure Player "Next"][!UpdateMeasure *][!SetVariable Curr "[*Track*]"][!CommandMeasure Player "Next"][!UpdateMeasure *][!SetVariable Next "[*Track*]"][!CommandMeasure Player "Previous"][!UpdateMeasure *][!UpdateMeter *][!Redraw][!SetVariable BangIndex 1]
BangR=[#Bang1][&Progress]
Prev=
Curr=
Next=
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[#BangR]
---Measures---
[Device]
Measure=Plugin
Plugin=Win7AudioPlugin
[Volume]
Measure=Calc
Formula=Device
RegExpSubstitute=1
Substitute="^-1$":"Mute"
[Player]
Measure=NowPlaying
PlayerName=#PlayerName#
PlayerType=State
[Repeat]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Repeat
Substitute="0":"Off","1":"On"
[Shuffle]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Shuffle
Substitute="0":"Off","1":"On"
[Progress]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Progress
MinValue=0
MaxValue=100
RegExpSubstitute=1
Substitute="^(.*)$":'[!CommandMeasure Player "SetPosition \1"]'
[Title]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Title
[Artist]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Artist
[Album]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=Album
[File]
Measure=NowPlaying
PlayerName=[Player]
PlayerType=File
[Track]
Measure=String
String=#Track#
RegExpSubstitute=1
Substitute="(?:^ - .*$|^.* - *- .*$|^.* - $)":"[File]","^(.*)\\(.*)\.(.*)$":"\2"
OnChangeAction=[#Bang[#BangIndex]]
DynamicVariables=1
---Meters---
[Container]
Meter=Shape
X=4
Y=4
W=600
H=110
Shape=Rectangle ([Container:X]),([Container:Y]),([Container:W]),([Container:H]),8 | Fill Color 0,0,0,255 | StrokeWidth 0
DynamicVariables=1
[Background]
Meter=Shape
Shape=Rectangle ([Container:X]),([Container:Y]),([Container:W]),([Container:H]),8 | Fill Color #FONTCOLORN# | StrokeWidth 2 | StrokeColor #FONTCOLOR#
[Prev]
Meter=String
Container=Container
X=8
Y=8R
W=[Background:W]
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
ClipString=1
AntiAlias=1
Text=#PreSym# #PreText# : #Prev#
LeftMouseUpAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Previous"][!UpdateMeasure *]
MouseScrollUpAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Previous"][!UpdateMeasure *]
MouseScrollDownAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Next"][!UpdateMeasure *]
DynamicVariables=1
[Curr]
Meter=String
Container=Container
X=8
Y=7R
W=[Background:W]
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
ClipString=1
AntiAlias=1
Text=#CurrSym# #CurrText# : #Curr#
LeftMouseUpAction=[!CommandMeasure Player "PlayPause"][!UpdateMeasure *]
MouseScrollUpAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Previous"][!UpdateMeasure *]
MouseScrollDownAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Next"][!UpdateMeasure *]
DynamicVariables=1
[Next]
Meter=String
Container=Container
X=8
Y=4R
W=[Background:W]
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
ClipString=1
AntiAlias=1
Text=#NextSym# #NextText# : #Next#
LeftMouseUpAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Next"][!UpdateMeasure *]
MouseScrollUpAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Previous"][!UpdateMeasure *]
MouseScrollDownAction=[!SetVariable BangIndex 1][!CommandMeasure Player "Next"][!UpdateMeasure *]
DynamicVariables=1
[ShuffleStatus]
Meter=String
Container=Container
X=20
Y=([Next:Y]+[Next:H]+4)
W=([Background:W]/4)
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
Text=Shuffle: [Shuffle]
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure Player "SetShuffle -1"][!UpdateMeasure *][!UpdateMeter ShuffleStatus][!Redraw]
DynamicVariables=1
[RepeatStatus]
Meter=String
Container=Container
X=([RepeatStatus:W]+[ShuffleStatus:X])
Y=([Next:Y]+[Next:H]+4)
W=([Background:W]/4)
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
Text=Repeat: [Repeat]
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure Player "SetRepeat -1"][!UpdateMeasure *][!UpdateMeter RepeatStatus][!Redraw]
DynamicVariables=1
[VolumeStatus]
Meter=String
Container=Container
X=([RepeatStatus:W]+[ShuffleStatus:X]+[ShuffleStatus:W]+12)
Y=([Next:Y]+[Next:H]+4)
W=([Background:W]/4)
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
Text=Volume: [Volume]
AntiAlias=1
LeftMouseUpAction=[!CommandMeasure Device "ToggleMute"][!UpdateMeasure *][!UpdateMeter VolumeStatus][!Redraw]
MouseScrollUpAction=[!CommandMeasure Device "ChangeVolume +2"][!UpdateMeasure *][!UpdateMeter VolumeStatus][!Redraw]
MouseScrollDownAction=[!CommandMeasure Device "ChangeVolume -2"][!UpdateMeasure *][!UpdateMeter VolumeStatus][!Redraw]
DynamicVariables=1
[ProgressStatus]
Meter=String
Container=Container
X=(([Background:W])-([Background:W]/4)+8)
Y=([Next:Y]+[Next:H]+4)
W=([Background:W]/4-8)
FontFace=#FONTNAME#
FontColor=#FONTCOLOR#
FontSize=#FONTSIZE#
AntiAlias=1
Text=Progress: [Progress:%,1]%
LeftMouseUpAction=[!CommandMeasure Player "Stop"][!CommandMeasure Player "Play"][!UpdateMeasure *]
MouseScrollUpAction=[!CommandMeasure Progress "SetPosition +2"][!UpdateMeasure *][!UpdateMeter ProgressStatus][!Redraw]
MouseScrollDownAction=[!CommandMeasure Progress "SetPosition -2"][!UpdateMeasure *][!UpdateMeter ProgressStatus][!Redraw]
MiddleMouseUpAction=[#Bang1]
DynamicVariables=1
There are multiple changes I made, so I'll just list them:
- added a Track variable where you can set whether you want just the title and artist or the album as well to be returned by the Track measure (this way, you don't have to change in a thousand places when you want a different return)
- continued to use Bang0 and Bang1 (Bang1 is the sole bang for getting track data in advance now, got rid of the rest), but added a little hack in BangR where, because of the commanding bangs in Bang1 reset the track position on jumping, I restore it by "executing" the string value of the Progress measure in the OnRefreshAction (just watch the string value of that measure in the
About > Skins tab and you'll understand what I mean; it's not perfect, but it's as good as it gets)
- set Update to 1000, it doesn't make any sense for it to be lower since the NowPlaying data is not retrieved at a frequency of less than 1 second anyway (this will slightly help with lowering the CPU usage too)
- added the ability to display the "Mute" text instead of "-1" on toggling the mute status, in the Volume measure
- aggregated sustitutions in the Track measure (by the way, the order of measures and meters is important, so the Artist measure should have been before the Track measure in your b.ini code in order for the latter to get the current value of the former properly)
- cleaned the code a bit, shuffled the order of some options, made stuff more compact (this one was just cosmetics, no functional purpose at all)
Notes:
- No, you can't workaround the couple of milliseconds when you hear the start of other songs when using the commanding bangs above. Regardless of the value of Update, there will always be a slight delay between the start of the song and Rainmeter getting the NowPlaying data or performing the OnChangeAction. Here, it pays off to have tracks where the music doesn't start right away and doesn't end abruptly - a possible alternative would be to configure the player to use a bit of fading in/out the sound when changing tracks though.
- One other thing neither of us considered when pursuing the OnChangeAction approach is that the skin will take exclusive control of playing when Shuffle in On. This means that if you try to play some track from your player with the skin loaded, it won't work. This is because the commanding bangs are jumping to tracks from the internal randomized list used by the player when getting the previous and next of them in advance. The solution is to temporarily toggle Shuffle to Off, and change the tracks from the player as desired. Of course, if toggling the Shuffle to On afterwards, the previous and next tracks won't be properly set back to the shuffled ones until the track is changed again (either by re-starting play, the track ending, or otherwise). But then, these are the drawbacks of a hack like this is, so it is what it is.
Feel free to ask if you don't understand something from the above, or further adjust the code to your preference.
![Wink ;-)](./images/smilies/innuendo.gif)