From e343ffee5a4663374a77073a3e4370041f2fc431 Mon Sep 17 00:00:00 2001 From: Sam Date: Sat, 1 Feb 2025 17:23:24 +0000 Subject: Add playlist browser Add a menu item to main menu and associated browser for playlist files in the root of the SD card --- lua/main_menu.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lua/main_menu.lua') diff --git a/lua/main_menu.lua b/lua/main_menu.lua index cc7874d7..80d5b599 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -131,6 +131,14 @@ return widgets.MenuScreen:new { }) end + local playlist_btn = indexes_list:add_btn(nil, "Playlists") + playlist_btn:onClicked(function() + backstack.push(require("playlist_browser"):new { + title = "Playlists", + }) + end) + playlist_btn:add_style(styles.list_item) + local function show_no_indexes(msg) indexes_list:add_flag(lvgl.FLAG.HIDDEN) no_indexes_container:clear_flag(lvgl.FLAG.HIDDEN) -- cgit v1.2.3 From 844b3f733ec30eff41c3b3d48c74561d7b11da8e Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 3 Feb 2025 20:13:23 +0000 Subject: Use Playlist subdirectory Target /Playlists, display and browse sub directories and playlists within --- lua/main_menu.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'lua/main_menu.lua') diff --git a/lua/main_menu.lua b/lua/main_menu.lua index 80d5b599..c8edf766 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -135,6 +135,7 @@ return widgets.MenuScreen:new { playlist_btn:onClicked(function() backstack.push(require("playlist_browser"):new { title = "Playlists", + iterator = filesystem.iterator("/Playlists") }) end) playlist_btn:add_style(styles.list_item) -- cgit v1.2.3 From ff733e8f0c827e3d2d91bb7db29a85807867ab5e Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Feb 2025 21:13:52 +0000 Subject: Wrap filesystem iterator Change to wrapping the filesystem iterator rather than iterating over table values. Also centralise the is_playlist check and hide Playlists menu if none are present --- lua/main_menu.lua | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lua/main_menu.lua') diff --git a/lua/main_menu.lua b/lua/main_menu.lua index c8edf766..fdf11956 100644 --- a/lua/main_menu.lua +++ b/lua/main_menu.lua @@ -11,7 +11,6 @@ local browser = require("browser") local playing = require("playing") local styles = require("styles") local filesystem = require("filesystem") -local screen = require("screen") local font = require("font") local theme = require("theme") local img = require("images") @@ -151,6 +150,14 @@ return widgets.MenuScreen:new { indexes_list:clear_flag(lvgl.FLAG.HIDDEN) end + local function hide_playlist_listing() + playlist_btn:add_flag(lvgl.FLAG.HIDDEN) + end + + local function show_playlist_listing() + playlist_btn:clear_flag(lvgl.FLAG.HIDDEN) + end + local function update_visible_indexes() local has_valid_index = false for _, idx in ipairs(indexes) do @@ -164,6 +171,13 @@ return widgets.MenuScreen:new { end if has_valid_index then hide_no_indexes() + + -- If we have valid indexes, then also check for playlists + if filesystem.iterator("/Playlists/"):next() == nil then + hide_playlist_listing() + else + show_playlist_listing() + end else if require("database").updating:get() then show_no_indexes("The database is updating for the first time. Please wait.") -- cgit v1.2.3