It is currently March 28th, 2024, 10:29 pm

Track Time Remaining?

General topics related to Rainmeter.
Vetsus
Posts: 27
Joined: March 7th, 2017, 5:29 pm

Track Time Remaining?

Post by Vetsus »

has anyone figured out how to get the track time remaining for the nowplaying plugin? i've tried several measures to do so with no luck. i really just like having the option to have that vs the track time itself.
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Track Time Remaining?

Post by CyberTheWorm »

Try looking at this https://docs.rainmeter.net/manual-beta/plugins/nowplaying/ it has all the information in there.

I would do a formula "Duration-Position=Timeleft"
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Track Time Remaining?

Post by jsmorley »

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[MeasureArtist]
Measure=Plugin
Plugin=NowPlaying
PlayerName=Winamp
PlayerType=Artist

[MeasureTitle]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureArtist]
PlayerType=Title

[MeasurePosition]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureArtist]
PlayerType=Position

[MeasureDuration]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureArtist]
PlayerType=Duration

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

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

[MeterPlayer]
Meter=String
MeasureName=MeasureArtist
MeasureName2=MeasureTitle
MeasureName3=MeasureDuration
MeasureName4=MeasurePosition
MeasureName5=MeasureMinutesRemaining
MeasureName6=MeasureSecondsRemaining
InlineSetting=Size | 11
InlineSetting2=Weight | 400
InlineSetting3=Color | 255,255,255,255
SolidColor=47,47,47,255
Padding=5,5,5,5
AntiAlias=1
Text=%1#CRLF#%2#CRLF#%3 | %4 | %5:%6
1.jpg
https://docs.rainmeter.net/manual-beta/formulas/#Formulas
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Track Time Remaining?

Post by balala »

Sorry CyberTheWorm and jsmorley, I just wrote my reply when you've posted yours, so I also post mine. I hope you don't mind...
Vetsus wrote:has anyone figured out how to get the track time remaining for the nowplaying plugin? i've tried several measures to do so with no luck. i really just like having the option to have that vs the track time itself.
The following [MeasureProgress] and [MeasureDuration] measures will return the progress and the duration of the current track (I also post the parent [MeasurePlayer] measure, just add the appropriate PlayerName variable to the [Variables] section):

Code: Select all

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=TITLE

[MeasureProgress]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=POSITION

[MeasureDuration]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=DURATION
The remaining time can be calculated subtracting the progress from the duration. But be careful, because the result will be expressed in seconds:

Code: Select all

[MeasureRemaining]
Measure=Calc
Formula=( MeasureDuration - MeasureProgress )
Now you have to convert this number into minutes and seconds (eventually hours, too). This conversion can be done by the following measures:

Code: Select all

[MeasureRemainingMinutes]
Measure=Calc
Formula=( Floor ( MeasureRemaining / 60 ))
RegExpSubstitute=1
Substitute="^(.)$":"0\1"

[MeasureRemainingSeconds]
Measure=Calc
Formula=( MeasureRemaining % 60 )
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
If you also need to calculate the number of hours, please let me know.
Note that I added the RegExpSubstitute and Substitute options to have both numbers with two digits (adding a 0 in front of the one digit number).
You have to use just a string meter to show the result, for example:

Code: Select all

[MeterRemaining]
MeasureName=MeasureRemainingMinutes
MeasureName2=MeasureRemainingSeconds
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
Text=Remained: %1:%2
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Track Time Remaining?

Post by jsmorley »

The more the merrier... ;-)
User avatar
CyberTheWorm
Posts: 860
Joined: August 22nd, 2016, 11:32 pm
Location: Surrey, B.C., Canada

Re: Track Time Remaining?

Post by CyberTheWorm »

LOL, I was just going to play and try and get the formula. You guys are just too fast. :great:
The only source of knowledge is experience. Albert Einstein
Deviant Art Page
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Track Time Remaining?

Post by jsmorley »

Only comment I would make balala, is that I think Trunc() is a better fit here than Floor(). We are never looking to "round" anything. I actually suspect either will always work, but Trunc() makes more sense to me.
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Track Time Remaining?

Post by balala »

jsmorley wrote:Only comment I would make balala, is that I think Trunc() is a better fit here than Floor(). We are never looking to "round" anything. I actually suspect either will always work, but Trunc() makes more sense to me.
Actually there are no differences here between Trunc and Floor, while their arguments are positive.
Take a look at the following example code:

Code: Select all

[MeasureTrunc]
Measure=Calc
Formula=( Trunc ( #Num# ))

[MeasureFloor]
Measure=Calc
Formula=( Floor ( #Num# ))
If the Num variable is positive (eg Num=2.24), both measures will return 2, as result. But if Num=-2.24, [MeasureTrunc] will return -2, while [MeasureFloor] will return -3. That's happening because Floor is always returning the largest integer number, lower than its argument (Num, in this case). If Num=-2.24, that's -3.
Trunc on the other hand, is returning the integer part of its argument (of Num, in this case). But the integer part of -2.24, is -2.
When the arguments are positive, both functions give the same result (eg for 2.24, both give 2).
Because here the argument (the remaining time) for sure is positive, doesn't matter which function are you using. It can be a question of personal preference, but doesn't matter too much.
Vetsus
Posts: 27
Joined: March 7th, 2017, 5:29 pm

Re: Track Time Remaining?

Post by Vetsus »

balala wrote:Sorry CyberTheWorm and jsmorley, I just wrote my reply when you've posted yours, so I also post mine. I hope you don't mind...


The following [MeasureProgress] and [MeasureDuration] measures will return the progress and the duration of the current track (I also post the parent [MeasurePlayer] measure, just add the appropriate PlayerName variable to the [Variables] section):

Code: Select all

[MeasurePlayer]
Measure=Plugin
Plugin=NowPlaying
PlayerName=#PlayerName#
PlayerType=TITLE

[MeasureProgress]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=POSITION

[MeasureDuration]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasurePlayer]
PlayerType=DURATION
The remaining time can be calculated subtracting the progress from the duration. But be careful, because the result will be expressed in seconds:

Code: Select all

[MeasureRemaining]
Measure=Calc
Formula=( MeasureDuration - MeasureProgress )
Now you have to convert this number into minutes and seconds (eventually hours, too). This conversion can be done by the following measures:

Code: Select all

[MeasureRemainingMinutes]
Measure=Calc
Formula=( Floor ( MeasureRemaining / 60 ))
RegExpSubstitute=1
Substitute="^(.)$":"0\1"

[MeasureRemainingSeconds]
Measure=Calc
Formula=( MeasureRemaining % 60 )
RegExpSubstitute=1
Substitute="^(.)$":"0\1"
If you also need to calculate the number of hours, please let me know.
Note that I added the RegExpSubstitute and Substitute options to have both numbers with two digits (adding a 0 in front of the one digit number).
You have to use just a string meter to show the result, for example:

Code: Select all

[MeterRemaining]
MeasureName=MeasureRemainingMinutes
MeasureName2=MeasureRemainingSeconds
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
Text=Remained: %1:%2
i'm unsure if i'm failing to do this right or if it doesn't work with spotify. is it confirmed that this works with spotify because it does not with mine...?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Track Time Remaining?

Post by balala »

Vetsus wrote:i'm unsure if i'm failing to do this right or if it doesn't work with spotify. is it confirmed that this works with spotify because it does not with mine...?
I wrote that code with the NowPlaying plugin. NowPlaying just partially supports Spotify, but on the forum you can find a plugin for Spotify: https://forum.rainmeter.net/viewtopic.php?p=94631#p94631
According to the manual, the NowPlaying plugin doesn't support the duration and position with Spotify, just the Artist and the Title, so probably my code doesn't work with Spotify. I don't use Spotify, so I can't even try it. Probably someone will help you here to adapt this to work with the SpotifyPlugin.
Sorry...