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

Bugs & Feature Suggestions • Re: [Friendly Resource] If PlayerType=Lyrics needs an update, LRCLIB can be used

$
0
0
I'm experiencing this problem with both options and never had it with the "original" setup.
Alright, after having slept on it I approached this a bit differently and managed to write the formulas in a way that allows for either of the "line always in the chosen vertical position" and "line in the chosen position only when not at the start or end of the lyrics" variants to be chosen, by simply changing the value of one of the two variables that I included in an improved version of the sample skin earlier (LockLine = 0 for the 2nd variant, 1 for the 1st variant; LockPerc = decimal percentage starting from the top of the lyrics container where the line should stay):

Code:

[Variables]BackgroundW=400BackgroundH=600StrokeWidth=2CornerRadius=10Margin=10BackgroundColor=0,0,0,128StrokeColor=255,128,0,255InfoColor0=255,128,128,255InfoColor1=128,128,255,255InfoColor2=128,255,128,255InfoColor3=255,128,255,255ControlColor0=255,255,128,255ControlColor1=128,255,255,255ControlColor2=128,255,255,255ControlColor3=255,255,128,255LyricsColor=192,192,192,255KaraokeColor=255,255,255,255FontEffectColor=0,0,0,255FontColor=255,255,255,255FontFace=Monotype CorsivaFontSize=16StringEffect=ShadowFontPerc=0.75BarHPerc=0.80BarSolid=128,128,128,255BarColor=0,255,0,255ControlNum=4ControlGap=50Prev=[\x23EE]Stop=[\x23F9]Play=[\x23F5]Next=[\x23ED]Pause=[\x23F8]BoxColor=0,0,0,128Plugin=NowPlayingPlayer=WinampOffset=0LockLine=0LockPerc=0LineH=0Lines=0Line=0[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Measures---[Status]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=#Player#PlayerType=StatusRegExpSubstitute=1Substitute="^0$":"Closed","^1$":"Open"DynamicVariables=1[State]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=StateRegExpSubstitute=1Substitute="^0$":"Stopped","^1$":"Playing","^2$":"Paused"IfCondition=(State=1)IfTrueAction=[!SetOption Play Text "#Pause#"]IfFalseAction=[!SetOption Play Text "#Play#"]DynamicVariables=1[Artist]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=ArtistRegExpSubstitute=1Substitute="^$":"No Artist"DynamicVariables=1[Album]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=AlbumRegExpSubstitute=1Substitute="^$":"No Album"DynamicVariables=1[Title]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=TitleRegExpSubstitute=1Substitute="^$":"No Title"DynamicVariables=1[Duration]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=DurationRegExpSubstitute=1Substitute="(?<!\d)(\d)(?!\d)":"0\1"DynamicVariables=1[Position]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=PositionRegExpSubstitute=1Substitute="(?<!\d)(\d)(?!\d)":"0\1"OnChangeAction=[!UpdateMeasureGroup LinesGroup]DynamicVariables=1[Progress]Group=PlayerGroupMeasure=PluginPlugin=#Plugin#PlayerName=[Status]PlayerType=ProgressDynamicVariables=1[Track]Group=PlayerGroupMeasure=StringString=[Artist] - [Album] - [Title] - [Duration:]OnChangeAction=[!SetVariable Line 0][!SetVariable Offset 0][!CommandMeasure SyncedLyrics "Update"]DynamicVariables=1[SyncedLyrics]Measure=WebParserURL=https://lrclib.net/api/get?artist_name=[&Artist]&album_name=[&Album]&track_name=[&Title]&duration=[&Duration:]UserAgent=Rainmeter 4.5.18 (https://github.com/rainmeter)RegExp=(?siU)[{,]"syncedLyrics":"(.*)"[,}]StringIndex=1UpdateRate=-1RegExpSubstitute=1Substitute='(?sU)\\"':'"',"(?sU)\\n":"#CRLF#"IfMatch=(?siU)\[\x005B][Position].+\RIfMatchAction=[!SetOption LyricsText "InlineSetting" "Color | #KaraokeColor#"][!SetOption LyricsText "InlinePattern" "(?siU)\[\x005B][Position].+\R"]IfMatchMode=1FinishAction=[!UpdateMeasureGroup LinesGroup]DynamicVariables=1[Lines]Group=LinesGroupMeasure=StringString=[SyncedLyrics]UpdateDivider=-1RegExpSubstitute=1Substitute="(?siU).+(?:\R|$)":"+1","(?siU)^(.*)$":"0\1","\\\d+":""OnUpdateAction=[!SetVariable Lines ([Lines])][!SetVariable LineH ([LyricsText:H]/([#Lines]=0?1:[#Lines]))]DynamicVariables=1[Line]Group=LinesGroupMeasure=StringString=[SyncedLyrics]UpdateDivider=-1RegExpSubstitute=1Substitute="(?siU)(?|^(.*)\[\x005B][Position].+(?:\R|$).*?$|^((?:.+(?:\R|$)){#Line#}).*?$)":"\1","\\\d+":"","(?siU).+(?:\R|$)":"+1","(?siU)^(.*)$":"0\1","\\\d+":""OnUpdateAction=[!SetVariable Line ([Position:]=0?0:[Line])][!SetVariable Offset ([#LineH]*[#Line])]DynamicVariables=1[Reset]Group=LinesGroupMeasure=CalcFormula=([Position:]=0?1:0)UpdateDivider=-1IfCondition=(Reset=1)IfTrueAction=[!SetOption LyricsText "InlineSetting" "Color | #KaraokeColor#"][!SetOption LyricsText "InlinePattern" "^$"]IfConditionMode=1OnUpdateAction=[!UpdateMeter *][!Redraw]DynamicVariables=1---Styles---[Texts]FontEffectColor=#FontEffectColor#FontColor=#FontColor#FontFace=#FontFace#FontSize=#FontSize#AntiAlias=1StringEffect=#StringEffect#---Meter---[Background]Meter=ShapeShape=Rectangle (#StrokeWidth#/2),(#StrokeWidth#/2),(#BackgroundW#-#StrokeWidth#),(#BackgroundH#-#StrokeWidth#),(#CornerRadius#),(#CornerRadius#) | Fill Color #BackgroundColor# | Stroke Color #StrokeColor# | StrokeWidth #StrokeWidth#UpdateDivider=-1[Information]Meter=StringMeterStyle=TextsStringAlign=CenterX=(#BackgroundW#/2)Y=(#Margin#)W=(#BackgroundW#-#Margin#*2)InlineSetting=Color | #InfoColor0#InlinePattern=^(?:\N*\R){0}(\N*)InlineSetting2=Color | #InfoColor1#InlinePattern2=^(?:\N*\R){1}(\N*)InlineSetting3=Color | #InfoColor2#InlinePattern3=^(?:\N*\R){2}(\N*)InlineSetting4=Color | #InfoColor3#InlinePattern4=^(?:\N*\R){3}(\N*)MeasureName=ArtistMeasureName2=AlbumMeasureName3=TitleMeasureName4=DurationMeasureName5=PositionMeasureName6=ProgressMeasureName7=StatusMeasureName8=StateText=%1#CRLF#%2#CRLF#%3#CRLF#%5 of %4 (%6%) - Player is %7 & %8DynamicVariables=1[ProgressBar]Meter=BarMeasureName=ProgressX=(#Margin#)Y=(#Margin#/2)RW=(#BackgroundW#-#Margin#*2)H=(#FontSize#*#BarHPerc#)BarColor=#BarColor#SolidColor=#BarSolid#BarOrientation=HorizontalLeftMouseDownAction=[!CommandMeasure Progress "SetPosition $MouseX:%$"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw]DynamicVariables=1[Prev]Meter=StringMeterStyle=TextsX=(#BackgroundW#/2-#ControlGap#/2*(#ControlNum#-1))Y=(#Margin#/2)RStringAlign=CenterFontColor=#ControlColor0#Text=#Prev#LeftMouseUpAction=[!CommandMeasure Status "Previous"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw][Stop]Meter=StringMeterStyle=TextsX=(#ControlGap#)rY=(0)rStringAlign=CenterFontColor=#ControlColor1#Text=#Stop#LeftMouseUpAction=[!CommandMeasure Status "Stop"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw][Play]Meter=StringMeterStyle=TextsX=(#ControlGap#)rY=(0)rStringAlign=CenterFontColor=#ControlColor2#Text=#Play#LeftMouseUpAction=[!CommandMeasure Status "PlayPause"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw][Next]Meter=StringMeterStyle=TextsX=(#ControlGap#)rY=(0)rStringAlign=CenterFontColor=#ControlColor3#Text=#Next#LeftMouseUpAction=[!CommandMeasure Status "Next"][!UpdateMeasureGroup PlayerGroup][!UpdateMeter *][!Redraw][LyricsBox]Meter=ImageX=(#Margin#)Y=(#Margin#/2)RW=(#BackgroundW#-#Margin#*2)H=(#BackgroundH#-[LyricsBox:Y]-#Margin#)SolidColor=#BoxColor#UpdateDivider=-1DynamicVariables=1[LyricsContainer]Meter=ImageX=([LyricsBox:X])Y=([LyricsBox:Y])W=([LyricsBox:W])H=([LyricsBox:H])SolidColor=0,0,0,255UpdateDivider=-1MouseScrollUpAction=[!SetVariable Offset (Clamp(#Offset#-#LineH#,[LyricsContainer:H]*#LockPerc#*(1-#LockLine#),Clamp([LyricsText:H]-[LyricsContainer:H]*(1-#LockLine#),0,[LyricsText:H])+[LyricsContainer:H]*#LockPerc#*(1-#LockLine#)))][!UpdateMeter LyricsContainer][!UpdateMeter LyricsText][!Redraw]MouseScrollDownAction=[!SetVariable Offset (Clamp(#Offset#+#LineH#,[LyricsContainer:H]*#LockPerc#*(1-#LockLine#),Clamp([LyricsText:H]-[LyricsContainer:H]*(1-#LockLine#),0,[LyricsText:H])+[LyricsContainer:H]*#LockPerc#*(1-#LockLine#)))][!UpdateMeter LyricsContainer][!UpdateMeter LyricsText][!Redraw]DynamicVariables=1[LyricsText]Container=LyricsContainerMeter=StringMeterStyle=TextsStringAlign=CenterFontColor=#LyricsColor#FontSize=(#FontSize#*#FontPerc#)X=([LyricsBox:W]/2)Y=(-Clamp(#Offset#-[LyricsContainer:H]*#LockPerc#,-[LyricsContainer:H]*#LockPerc#*#LockLine#,Clamp([LyricsText:H]-[LyricsContainer:H],0,[LyricsText:H])+[LyricsContainer:H]*(1-#LockPerc#)*#LockLine#))W=([LyricsBox:W])MeasureName=SyncedLyricsText=%1DynamicVariables=1
The improved sample includes:
- the ability to work with either NowPlaying or WebNowPlaying, by changing the value of the Plugin variable in [Variables] accordingly
- the ability to loosely or strictly "lock" the vertical position of the current line in the lyrics box via the LockLine and LockPerc variables, see above
- the ability to detect changing the track for either plugin, as mentioned earlier in the thread, via the [Track] measure
- corrections to the way the current line is computed, see the slightly adjusted Substitute in the [Line] measure
- the ability to reset the highlighted / karaoke line to nothing when the track position is 0 (aka track is stopped), in the [Reset] measure
- the adjusted formulas for any variant of locking the current line vertical position, in the scroll actions of [LyricsContainer] and the Y of [LyricsText]

Feel free to add what you prefer in the code you posted above. You can use a LockLine of 0 for the loose lock or 1 for the strict lock, and a LockPerc of 0.43 as per your code. Alternatively, if you don't like adding the variables or the longer formulas and you only need one of the position locking variants, you can skip adding the variables and just replace #LockLine# and #LockPerc# with your chosen values in the formulas and, when possible, reduce the formulas if some terms cancel each other or themselves out.

What's probably left to do if desired is to allow horizontal scrolling too, in case the lyrics lines are too long to fit the container (considering that wrapping them has unwanted effects on computing the line height, aka #LineH#). I suppose that would work best on mouse hovering near the left and right sides of the container, since mouse scrolling on the container is already populated by the vertical scrolling. I'll let you do that if you want, since it's trivial to change the X of [LyricsText] from some MouseOverAction / MouseLeaveAction in [LyricsContainer] (the result should be clamped though, so that it doesn't go forever).

Statistics: Posted by Yincognito — Today, 8:08 pm



Viewing all articles
Browse latest Browse all 1132

Trending Articles