Show the now playing screen after being locked for a while

This commit is contained in:
jacqueline
2024-03-07 11:16:56 +11:00
parent ef72b25660
commit eba5adeb8c
3 changed files with 22 additions and 0 deletions
+17
View File
@@ -1,8 +1,13 @@
local font = require("font")
local vol = require("volume")
local controls = require("controls")
local time = require("time")
local lock_time = time.ticks()
-- Set up property bindings that are used across every screen.
GLOBAL_BINDINGS = {
-- Show an alert with the current volume whenver the volume changes.
vol.current_pct:bind(function(pct)
require("alerts").show(function()
local container = lvgl.Object(nil, {
@@ -32,6 +37,18 @@ GLOBAL_BINDINGS = {
container:center()
end)
end),
-- When the device has been locked for a while, default to showing the now
-- playing screen after unlocking.
controls.lock_switch:bind(function(locked)
if locked then
lock_time = time.ticks()
elseif time.ticks() - lock_time > 8000 then
local queue = require("queue")
if queue.size:get() > 0 then
require("playing"):pushIfNotShown()
end
end
end),
}
local backstack = require("backstack")