Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1754

General Discussion • Re: Next and Previous Track's Names

$
0
0

Code:

[Title]Measure=NowPlayingPlayerName=[Player]PlayerType=Title;OnChangeAction=[!Refresh][!Delay 250][!Refresh][!ShowFade][!Delay 20000][!HideFade]OnChangeAction=[!Refresh][!Delay 250][!CommandMeasure Player "Previous"][!UpdateMeasure *][!WriteKeyValue Variables Prev "[Title] - [Artist] - [Album]"][!UpdateMeasure *][!CommandMeasure Player "Next"][!UpdateMeasure *][!WriteKeyValue Variables Curr "[Title] - [Artist] - [Album]"][!UpdateMeasure *][!CommandMeasure Player "Next"][!UpdateMeasure *][!WriteKeyValue Variables Next "[Title] - [Artist] - [Album]"][!UpdateMeasure *][!CommandMeasure Player "Previous"][!UpdateMeasure *][!Refresh];<Prev><SavePrev #Prev#>, ;<Next> <SaveCurr #Curr#>, ;<Next> <SaveNext #Next#>, ;<Prev>
I have broken up the pieces for clarity. I don't save it that way. It plays the track till the delay kicks in (I think). What did I do wrong?
Edit: Wrong Code at end. [!CommandMeasure Player "Next"][!UpdateMeasure *]
My bad, I think I missed one key detail in doing these things in the OnChangeAction of such a measure: the said option will react when the value of the measure it is attached to changes, BUT, very important, commanding the player to all these previous and next events itself triggers again the OnChangeAction, so in effect, an endless loop is created. E.g. the first "normal" OnChangeAction leads to commanding bang jumps, the bang jumps lead to another OnChangeAction, this OnChangeAction leads to another series of bang jumps, those bangs lead to another OnChangeAction, and so on forever.

The above issue can be solved by only running these commanding bangs a single time, right after clicking to change the track, and revert to no action otherwise. This is slightly more complex in nature, though easy to understand once you get familiar with the techniques. So, to do that, you can:
- save the bangs as variables whose names end in an "index" number, see the BangsN variables below (to have these bangs stored literally, without Rainmeter attempting to replace whatever contained variables or measures with their values, you'd have to escape such occurrences in the said bangs)
- use another variable storing the current "index", see the BangsIndex variable below (this variable will be used as part of the name of the BangsN variables, via nesting)
- on click, briefly changing the BangsIndex variable so that the proper BangsN (Bangs1 here) run once, followed by reverting it to normal (reset it to 0) in the same BangsN to avoid triggering the commanding bangs again (the OnChangeAction will simply "execute" the proper BangsN variable, so either Bangs1 to get data or Bangs0 to do nothing)

I've applied the above along with a [Track] measure holding the desired track data to my earlier simpleton code, for easier understanding - feel free to change or apply to your skin, after noticing the differences:

Code:

[Variables]PlayerName=WinampPrev=Curr=Next=BangsIndex=0Bangs0=[]Bangs1=[!SetVariable BangsIndex 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][Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1BackgroundMode=2SolidColor=0,255,0,255---Measures---[Player]Measure=NowPlayingPlayerName=#PlayerName#PlayerType=State[Repeat]Measure=NowPlayingPlayerName=[Player]PlayerType=Repeat[Shuffle]Measure=NowPlayingPlayerName=[Player]PlayerType=Shuffle[Artist]Measure=NowPlayingPlayerName=[Player]PlayerType=Artist[Title]Measure=NowPlayingPlayerName=[Player]PlayerType=Title[Album]Measure=NowPlayingPlayerName=[Player]PlayerType=Album[Progress]Measure=NowPlayingPlayerName=[Player]PlayerType=ProgressMinValue=0MaxValue=100[File]Measure=NowPlayingPlayerName=[Player]PlayerType=FileRegExpSubstitute=1Substitute="^(.*)\\(.*)\.(.*)$":"\2"[Track]Measure=StringString=[Title] - [Artist] - [Album]RegExpSubstitute=1Substitute="(?:^ - .*$|^.* - *- .*$|^.* - $)":"[File]"OnChangeAction=[#Bangs[#BangsIndex]]DynamicVariables=1---Meters---[Prev]Meter=StringY=10RAntiAlias=1Text=Prev: #Prev#LeftMouseUpAction=[!SetVariable BangsIndex 1][!CommandMeasure Player "Previous"]DynamicVariables=1[Curr]Meter=StringY=10RAntiAlias=1Text=Curr: #Curr#LeftMouseUpAction=[!CommandMeasure Player "PlayPause"][!UpdateMeasure *][!SetVariable Curr "[Track]"][!UpdateMeter *][!Redraw]MiddleMouseUpAction=[!CommandMeasure Player "Stop"]DynamicVariables=1[Next]Meter=StringY=10RAntiAlias=1Text=Next: #Next#LeftMouseUpAction=[!SetVariable BangsIndex 1][!CommandMeasure Player "Next"]DynamicVariables=1
So, the bangs themselves are more or less the same as you tried (I have the feeling you abuse !Refresh though, many times things can be done in the same loading session by setting variables in memory too, updating stuff and redrawing, even if you !WriteKeyValue things). Only the things pertaining to avoiding an endless loop and an aggregated track measure are added, but you can place your OnChangeAction in the Title measure if you really want that (despite the potential inaccuracy).

Statistics: Posted by Yincognito — Yesterday, 7:48 pm



Viewing all articles
Browse latest Browse all 1754

Trending Articles