mpv-progressbar icon indicating copy to clipboard operation
mpv-progressbar copied to clipboard

Total duration instead of system time

Open slideray opened this issue 6 years ago • 2 comments

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

slideray avatar Jul 19 '19 12:07 slideray

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.

torque avatar Aug 19 '19 20:08 torque

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

slideray avatar Aug 22 '19 19:08 slideray