Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Total duration instead of system time #52

Open
slideray opened this issue Jul 19, 2019 · 2 comments
Open

Total duration instead of system time #52

slideray opened this issue Jul 19, 2019 · 2 comments

Comments

@slideray
Copy link

How to display total duration instead of system time?
(Or replace the remaining time with the total time)

@torque
Copy link
Owner

torque commented Aug 19, 2019

This is not currently configurable, though it would be trivial to modify your local copy of progressbar.lua in either of the two following ways:

replace system clock time with file duration

diff --git a/progressbar.lua b/progressbar.lua
index 2792376..83633ce 100644
--- a/progressbar.lua
+++ b/progressbar.lua
@@ -2304,11 +2304,11 @@ do
     end,
     redraw = function(self)
       if self.active then
-        local systemTime = os.time()
-        if systemTime ~= self.lastTime then
+        local duration = math.floor(mp.get_property_number('duration', 0))
+        if duration ~= self.lastTime then
           local update = true
-          self.line[4] = os.date(timeFormat, systemTime)
-          self.lastTime = systemTime
+          self.line[4] = ('%d:%02d:%02d'):format(math.floor(duration / 3600), math.floor((duration / 60) % 60), math.floor(duration % 60))
+          self.lastTime = duration
           self.needsUpdate = true
         end
       end

replace time remaining with file duration

diff --git a/progressbar.lua b/progressbar.lua
index 2792376..220763a 100644
--- a/progressbar.lua
+++ b/progressbar.lua
@@ -1905,7 +1905,7 @@ do
     redraw = function(self)
       if self.active then
         _class_0.__parent.__base.redraw(self)
-        local timeRemaining = math.floor(mp.get_property_number('playtime-remaining', 0))
+        local timeRemaining = math.floor(mp.get_property_number('duration', 0))
         if timeRemaining ~= self.lastTime then
           local update = true
           self.line[4] = ('–%d:%02d:%02d'):format(math.floor(timeRemaining / 3600), math.floor((timeRemaining / 60) % 60), math.floor(timeRemaining % 60))

I have some bigger plans long term to improve configurability in this regard, but I've been quite busy recently and I'm not sure when I'll have time to really dig into that.

@slideray
Copy link
Author

Thank you very very much! Its work! Its best interface!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants