From 3276d113fcae2a73a1df6a32af73556a3a78b21f Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 11 Apr 2024 16:37:57 +1000 Subject: [PATCH] Use a fix scrubber range on the playing screen this ensure that the amount the scrubber moves for each tick of the input remains consistent, even when tracks have very different durations --- lua/playing.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lua/playing.lua b/lua/playing.lua index a88cd961..c5f54b98 100644 --- a/lua/playing.lua +++ b/lua/playing.lua @@ -123,7 +123,10 @@ return screen:new { } scrubber:onevent(lvgl.EVENT.RELEASED, function() - playback.position:set(scrubber:value()) + local track = playback.track:get() + if not track then return end + if not track.duration then return end + playback.position:set(scrubber:value() / 100 * track.duration) end) local controls = self.root:Object { @@ -202,7 +205,10 @@ return screen:new { text = format_time(pos) } if not scrubber:is_dragged() then - scrubber:set { value = pos } + local track = playback.track:get() + if not track then return end + if not track.duration then return end + scrubber:set { value = pos / track.duration * 100 } end end), playback.track:bind(function(track) @@ -212,9 +218,6 @@ return screen:new { } title:set { text = track.title } artist:set { text = track.artist } - scrubber:set { - range = { min = 0, max = track.duration } - } end), queue.position:bind(function(pos) if not pos then return end