Skip to content

Commit 7459d8a

Browse files
committed
HoverTime: redraw when duration changes
This was a bit of an oversight on how this was redrawn previously. For example changing between two videos with the same resolution but different duration, the time hovered would not update until the mouse moved. In theory it's possible for the duration to change while a video is playing I guess (but normally this would be for streamed video, for which we don't present the hover time at all) so that's another edge case potentially handled.
1 parent 606412b commit 7459d8a

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/HoverTime.moon

+14-5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class HoverTime extends BarAccent
1515
[[????]]
1616
}
1717

18+
@lastDuration = 0
1819
@lastTime = 0
1920
@lastX = -1
2021
@position = offScreenPos
@@ -42,14 +43,22 @@ class HoverTime extends BarAccent
4243
redraw: =>
4344
if @active
4445
super!
45-
if Mouse.x != @lastX
46+
47+
duration = mp.get_property_number( 'duration', 0 )
48+
49+
if Mouse.x != @lastX or duration != @lastDuration
50+
@lastDuration = duration
51+
4652
@line[2] = ("%g,%g")\format clamp( Mouse.x, leftMargin, Window.w - rightMargin ), @position
4753
@lastX = Mouse.x
4854

49-
hoverTime = mp.get_property_number( 'duration', 0 ) * Mouse.x / Window.w
50-
if hoverTime != @lastTime
51-
@line[4] = ([[%d:%02d:%02d]])\format math.floor( hoverTime/3600 ), math.floor( (hoverTime/60)%60 ), math.floor( hoverTime%60 )
52-
@lastTime = hoverTime
55+
if duration == 0
56+
@line[4] = "????"
57+
else
58+
hoverTime = duration * Mouse.x / Window.w
59+
if hoverTime != @lastTime
60+
@line[4] = ([[%d:%02d:%02d]])\format math.floor( hoverTime / 3600 ), math.floor( (hoverTime / 60) % 60 ), math.floor( hoverTime % 60 )
61+
@lastTime = hoverTime
5362

5463
@needsUpdate = true
5564

0 commit comments

Comments
 (0)