It is currently April 20th, 2024, 11:59 am

NowPlaying Plugin Position Calculation

Get help with creating, editing & fixing problems with skins
User avatar
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

NowPlaying Plugin Position Calculation

Post by Slim08 »

Hi, I'm trying to get the time code of my media player skin to show the track position inverted. Lets say a track is 3:50 min long - now it would normally show 0:00 up to 3:50. What I'm going for is that the track is starting at -3:50 counting down to 0:00. I managed to kind of get the result I want but the measurement is in plain seconds and not in minutes and seconds (MM:SS)

Code: Select all

[MeasureNegativeTimer]
Measure=Calc
Formula=( MeasurePosition - MeasureDuration )
what do I have to add so that the measurement comes out as MM:SS?
User avatar
balala
Rainmeter Sage
Posts: 16148
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: NowPlaying Plugin Position Calculation

Post by balala »

Slim08 wrote: November 3rd, 2018, 3:58 pm what do I have to add so that the measurement comes out as MM:SS?
You have to convert the number of seconds into minutes and seconds. For this, the first step will be to calculate not the difference between the position and duration, but vice-versa: between duration and position. This will be a positive number and you'll be able to work less complicated with it.
Secondly you'll need measures to calculate the number of minutes and the number of seconds. Replace the [MeasureNegativeTimer] measure with the following two:

Code: Select all

[MeasureNegativeTimerMinutes]
Measure=Calc
Formula=( Floor (( MeasureDuration - MeasurePosition ) / 60 ))
RegExpSubstitute=1
Substitute="^(.)$":"0\1"

[MeasureNegativeTimerSeconds]
Measure=Calc
Formula=(( MeasureDuration - MeasurePosition ) - 60 * MeasureNegativeTimerMinutes )
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
As I think you figured out, [MeasureNegativeTimerMinutes] calculates the number of minutes, while [MeasureNegativeTimerSeconds] the number of seconds, obviously. The Substitutions add the needed leading zero in front of the one-digit numbers.
The last step is to show up the result with a preceding minus. For this you have to use the following options into a String meter:

Code: Select all

[MeterTime]
Meter=STRING
MeasureName=MeasureNegativeTimerMinutes
MeasureName2=MeasureNegativeTimerSeconds
...
Text=-%1:%2
Due to the minus sign used into the Text option, the result is shown up as negative, although it is positive.
User avatar
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

Re: NowPlaying Plugin Position Calculation

Post by Slim08 »

I get how your workaround works but is there really no other way to convert the measurement from negative seconds to negative minutes and seconds? I mean rainmeter is already calculating correctly in some sense with my simple formula - I just thought there would be a way to add something like autoscale to brake down the measurement in the next higher unit.
User avatar
Slim08
Posts: 23
Joined: October 8th, 2018, 4:38 pm

Re: NowPlaying Plugin Position Calculation

Post by Slim08 »

Anyway your code works like a charm (as usual).

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

Re: NowPlaying Plugin Position Calculation

Post by balala »

Slim08 wrote: November 3rd, 2018, 5:24 pm I get how your workaround works but is there really no other way to convert the measurement from negative seconds to negative minutes and seconds? I mean rainmeter is already calculating correctly in some sense with my simple formula - I just thought there would be a way to add something like autoscale to brake down the measurement in the next higher unit.
No, there is no such a way. But you can operate with negative numbers, too. But anyway you have to make those calculations.
To show a way to operate with negative numbers, here is a workaround. Use your originally posted [MeasureNegativeTimer] measure and the following measures to calculate the number of minutes and seconds:

Code: Select all

[MeasureNegativeTimer]
Measure=Calc
Formula=( MeasurePosition - MeasureDuration )

[MeasureNegativeTimerMinute]
Measure=Calc
Formula=( Ceil ( MeasureNegativeTimer / 60 ))
RegExpSubstitute=1
Substitute="(\d{1})$":"0\1"

[MeasureNegativeTimerSecond]
Measure=Calc
Formula=( Abs (( 60 * MeasureNegativeTimerMinute + 1 + MeasureNegativeTimer ) % 60 ))
RegExpSubstitute=1
Substitute="^(\d{1})$":"0\1"
No way to use a simple option as you wanted.
Slim08 wrote: November 3rd, 2018, 6:29 pm Anyway your code works like a charm (as usual).

Thank you balala :welcome:
I'm glad if you got it working and also thanks for the kind words.