Latest restricted WACUP beta release is build #18980 (April 24th 2024) (x86 & x64 changelogs) | Latest WACUP public preview is build #18980 (April 24th 2024) (x86 only)


NOTE: Beta testers are added in a limited & subjective manner as I can only support so many people as part of the beta test program to keep it useful for my needs.

Unless I think you're going to be helpful, not all requests will be accepted but might still be later on. Remember that beta testing is to help me & the limitations currently works for my needs for this project.

Author Topic: Elapsed time and remaining time mismatch fixed  (Read 2251 times)

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Elapsed time and remaining time mismatch fixed
« on: May 31, 2023, 06:52:01 PM »
If you have a text object with the display="timeelapsed" parameter and another one with display="timeremaining" then the sum of their moduli will be 1 second less than the length of the song, e.g. song length 4:15, elapsed 1:22, remaining -2:52. This is because Winamp invariably rounds down decimals when converting milliseconds to MM:SS format. Thanks Aminifu for pointing out the issue.

Scripts to fix the mismatch and a proof-of-concept skin
« Last Edit: June 23, 2023, 08:00:28 AM by ariszlo »

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #1 on: June 01, 2023, 12:15:04 PM »
Hi ariszlo,

Thank you very very much for the scripts that fix the rounding issue with the time-elapsed and time-remaining counters.

I tried the threetimers.maki script with the Big Bento skin and I must be doing something wrong. The timers work correctly (removing the 1 second error), but I get script errors saying null objects are being called in the threetimers script and 2 others (in WACUP and Winamp).

All I did was replace the following code in the player-normal-group.xml file

        <text id="SongTime"
           x="7" y="8" h="31" w="102"
            font="player.bitmapfont.nums" timecolonwidth="6"
           display="time" align="left" alpha="220"
        />

with the following code

           <text id="remaining time"
           x="0" y="6" h="30" w="85"
           font="player.bitmapfont.nums" timecolonwidth="6"
           align="left" alpha="220"
   
        />

           <text id="elapsed time"
           x="100" y="6" h="30" w="85"
           font="player.bitmapfont.nums" timecolonwidth="6"
           align="left" alpha="220"
   
        />

        <script file="scripts/threetimers.maki"/>


« Last Edit: June 01, 2023, 12:40:54 PM by Aminifu »
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #2 on: June 01, 2023, 05:44:46 PM »
Hi Aminifu,

You get a null object called error if the script fails to find an xml object in your xml.

Maki scripts use the findObject or getObject command to find xml objects.

Two of Big Bento's scripts, songticker.maki and visualizer.maki, require that you have a text object with the id "SongTime". As I can see from your post, you have replaced the text object with the id "SongTme" with two text objects, neither of whose id is "SongTime". Without a text object with the id "SongTime", you break both songticker.maki and visualizer.maki and get two guru meditations.

Unlike songtime.maki, threetimers.maki was not designed specifically for Bento. If you look into it, you will see that it requires three text objects: one with the id "song length", another one with "elapsed time", and a third one with "remaining time".

Your xml breaks three scripts: Bento's songticker.maki and visualizer.maki because they cannot find "SongTime", and my threetimers.maki because it cannot find "song length". So all in all, you get three guru meditations.

If you want to adapt threetimers.maki to Big Bento then you will have to change the id of one of your timers to "SongTime" in both your xml and in the maki source (threetimers.m).

Let's say you change the id of the timer showing remaining time. Then you will have to change this line in threetimers.m:
  remainingText = thisGroup.getObject("remaining time");
to this:
  remainingText = thisGroup.getObject("SongTime");

As I can see from your post, you only want 2 timers: one for remaining time and one for elapsed time. The first thing you need to do then is to remove lengthText from this line:
  Global Text lengthText, elapsedText, remainingText;
So you will have this:
  Global Text elapsedText, remainingText;

Now that you have removed lengthText from the above line, remove every line that has a variable with length in its name: lengthText, lengthString, lengthLeft, lengthRight, roundLength.

Be careful though: getPlayItemLength() is NOT a variable, it is a function. We know it is a function because it is followed by parentheses. So do NOT remove this line:
  String remainingString = floatToString((getPlayItemLength() - getPosition())/1000, 1);

But, of course, remove this with the lengthString variable:
  String lengthString = floatToString(getPlayItemLength()/1000, 1);

Save your modified file (preferably changing its name to something like twotimers.m) and compile it.
« Last Edit: June 01, 2023, 09:00:22 PM by ariszlo »

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #3 on: June 01, 2023, 11:01:20 PM »
Thank you for the quick reply.  I'm still pretty much a novice understanding scripts and customizing xml files. You have taught me so much. I now understand what I did wrong.

My quick fix for now (instead of rewriting and compiling the scripts) is to add code for the missing objects and have them display were they will not be seen (using x="0" and h="0").

Last question on this topic. I promise.   ;)

Is it possible to remove the space between the colon and the seconds in the time-elapsed and time-remaining objects? I can live with the space. It was the 1 second error that was bugging me and now it's gone thanks to your script. Now, I think I'll be able to successfully use it with other modern skins where equivalent objects are used and the rounding issue is exposed.   ;D

« Last Edit: June 01, 2023, 11:04:35 PM by Aminifu »
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #4 on: June 02, 2023, 05:43:37 AM »
Thank you for the quick reply.

You're welcome. :)

Last question on this topic. I promise.   ;)

Promises like that are hard to keep. ;)

Is it possible to remove the space between the colon and the seconds in the time-elapsed and time-remaining objects?

Reduce the value of the timecolonwidth parameter. You can even go negative.

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #5 on: June 02, 2023, 08:58:47 AM »
Reduce the value of the timecolonwidth parameter. You can even go negative.

That didn't work. I changed the value from "6" to "1" and the space didn't change (even tried "-5").

P.S.
I found the problem. I needed to include the display="time" parameter in my code.
« Last Edit: June 02, 2023, 09:36:52 AM by Aminifu »
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #6 on: June 02, 2023, 02:40:09 PM »
I found the problem. I needed to include the display="time" parameter in my code.

Very good! Yours is a much better solution for the problem than mine with an unnecessarily complicated maki script written for Calvaria 2 years ago.

In addition to "time", it also works with "timeelapsed" and "timeremaining" but not with "songlength".

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #7 on: June 02, 2023, 07:33:34 PM »
In addition to "time", it also works with "timeelapsed" and "timeremaining" but not with "songlength".

Good for me since I don't need "songlength". That value is already show (or can be i.e. ATF string) in other places. Years ago I tried to find a way to remove it from the Playlist Editor window, but I've gotten used to it being there now.
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #8 on: June 03, 2023, 06:42:33 AM »
LOL, I just realized my last post was off point. You were talking about what can be used with 'display= '.

I use a trial and error approach, after looking at what real skinners have done, to customize skins for my use. With so many different ways to accomplish stuff, I truly admire what you guys do (simple or complicated).
« Last Edit: June 03, 2023, 07:08:32 AM by Aminifu »
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #9 on: June 18, 2023, 10:19:44 PM »
A whole package of makis to fix the mismatch between song length and the sum of elapsed time and remaining time:
  • elapsed-remaining.maki shows elapsed time and remaining time in a single text object with the id "SongTime". By default, elapsed time is to the left and remaining time is to the right. Left-click to swap.
  • round-elapsed-time.maki shows elapsed time in a text object with the id "elapsed time".
  • round-remaining-time.maki shows remaining time in a text object with the id "remaining time".
  • songtime.maki displays elapsed time, remaining time and song length in a single text object.
  • twotimers.maki displays elapsed time and remaining time in two different text objects.
  • jvc-clock.maki shows elapsed time and remaining time if playback is on and time of day if off.

Update 1 (2023-06-18): fixed a bug reported by dro:
I've found that when the skin first loads in a paused state it'll show the 'old' elapsed time & then adjusts to the 'corrected' elapsed time.

Update 2 (2023-06-19): replaced threetimers.maki with twotimers.maki because it turned out that song length needs no rounding.
« Last Edit: June 19, 2023, 06:24:39 PM by ariszlo »

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #10 on: June 18, 2023, 10:27:42 PM »
Since Big Bento Modern is licensed under the CC BY-NC-SA 4.0 license, I take the liberty and post my modifications of its songticker makis to fix the issue that the sum of elapsed time and remaining time is 1 second less than the length of the song.

Update (2023-06-18): fixed a bug reported by dro:

I've found that when the skin first loads in a paused state it'll show the 'old' elapsed time & then adjusts to the 'corrected' elapsed time.

Aminifu

  • Beta Tester
  • Hero Member
  • *****
  • Posts: 1136
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #11 on: June 19, 2023, 02:12:51 AM »
Hi ariszlo,

Question before I switch to the latest script.

I'm not seeing any mismatch with the previous script. When I load WACUP with BBM I only see "00:00" displayed. After I start playback both the top and bottom timers display the elapsed time. I can then click on either timer to switch it to remaining time. Is this the mismatch you're talking about?

If I load WACUP with another skin, start and pause playback, then switch to BBM, the remaining and elapsed times are correct.

« Last Edit: June 19, 2023, 02:20:35 AM by Aminifu »
Windows 11 Home 64-bit v23H2
Logitech Z906 5.1 speaker system

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Re: Elapsed time and remaining time mismatch fixed
« Reply #12 on: June 19, 2023, 06:51:07 AM »
I just repeated the old text, slightly rephrased before telling what's new.

The only new thing is that the new versions of the elapsed-remaining and bbm-rounded-timers scripts fix a minor bug reported by DrO (or so far it seems so): if you switched to a skin using these scripts while playback was paused from a skin that does not use them then elapsed/remaining time was not immediately adjusted.

ariszlo

  • Moderator
  • Hero Member
  • *****
  • Posts: 217
    • View Profile
Times
« Reply #13 on: June 22, 2023, 10:21:37 PM »
A proof-of-concept skin to show in action how milliseconds are rounded to the nearest second to fix the mismatch between song length and the sum of elapsed time and remaining time.
« Last Edit: June 22, 2023, 10:33:14 PM by ariszlo »