Vetsus wrote:but here is the code for the track progress or track time, as well as the track length:
Although I still don't use Spotify (as well as neither eclectic-tech doesn't), I will try however a reply. Don't take this as a fact, I'm not sure it'll entirely work, but if you won't get a better reply, maybe it worth a try...
According to the above posted code, it seems that the Spotify plugin returns the position and the length in the MM:SS format (I think this, due to the Substitute options, posted on both measures). First remove those two Substitute options (or at least comment them out, with some semicolons).
Then you'll need some measures, to convert the returned string format of the duration and progress, into seconds. Add the following measures to your code:
Code: Select all
[Measure_TrackTimeMinutes]
Measure=String
String=[Measure_TrackTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d+):(\d+)$":"\1"
[Measure_TrackTimeSeconds]
Measure=String
String=[Measure_TrackTime]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d+):(\d+)$":"\2"
[Measure_TrackLengthMinutes]
Measure=String
String=[Measure_TrackLength]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d+):(\d+)$":"\1"
[Measure_TrackLengthSeconds]
Measure=String
String=[Measure_TrackLength]
DynamicVariables=1
RegExpSubstitute=1
Substitute="^(\d+):(\d+)$":"\2"
The [Measure_TrackTimeMinutes] and [Measure_TrackTimeSeconds] measures will return the number of minutes, respectively seconds of the current position (changing while the playback is in progress), while the [Measure_TrackLengthMinutes] and [Measure_TrackLengthSeconds] measures will return the number of minutes and seconds of the duration.
Now with two Calc measures, you can calculate the number seconds of both (the position and the length):
Code: Select all
[Measure_TrackTime_InSeconds]
Measure=Calc
Formula=( 60 * [Measure_TrackTimeMinutes] + [Measure_TrackTimeSeconds] )
DynamicVariables=1
[Measure_TrackLength_InSeconds]
Measure=Calc
Formula=( 60 * [Measure_TrackLengthMinutes] + [Measure_TrackLengthSeconds] )
DynamicVariables=1
After all this is done, I think calculating the remaining time as a difference, is not too hard:
Code: Select all
[MeasureRemaining_InSeconds]
Measure=Calc
Formula=( Measure_TrackLength_InSeconds - Measure_TrackTime_InSeconds )
This last measure, will return the remaining time in seconds. You can easily convert the number, into a time format, using two Calc measures:
Code: Select all
[MeasureRemaining_Minutes]
Measure=Calc
Formula=( Floor ( MeasureRemaining_InSeconds / 60 ))
RegExpSubstitute=1
Substitute="^(\d{1})$":"0\1"
[MeasureRemaining_Seconds]
Measure=Calc
Formula=( MeasureRemaining_InSeconds - 60 * MeasureRemaining_Minutes )
RegExpSubstitute=1
Substitute="^(\d{1})$":"0\1"
Obviously the [MeasureRemaining_Minutes] measure will return the number of remained minutes and the [MeasureRemaining_Seconds] measure, the number of remained seconds.
Because I could try this code only with the NowPlaying plugin, I'm not very sure it'll work with the SpotifyPlugin. But try it, then please let me know if it does.
Vetsus wrote:i'm sorry, i didn't see this until obviously awhile later so i'm hoping i can still get some help with this.
About this, just mention that if you check the "Notify me when a reply is posted" checkbox below the field where you write your reply, you'll get an emaile, once someone replied to your message. Very easy and convenient, to not miss a reply...