diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-04-11 16:37:57 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-04-11 16:37:57 +1000 |
| commit | 3276d113fcae2a73a1df6a32af73556a3a78b21f (patch) | |
| tree | e27c7d3a31a35c7282c7b2b20b09309b83f3bb8f /lua/playing.lua | |
| parent | d1bf21fcf7869da8ece029b34161a72edc5d6825 (diff) | |
| download | tangara-fw-3276d113fcae2a73a1df6a32af73556a3a78b21f.tar.gz | |
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
Diffstat (limited to 'lua/playing.lua')
| -rw-r--r-- | lua/playing.lua | 13 |
1 files 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 |
