From b34959917446ac5d47ddec7bb6d98a6397045558 Mon Sep 17 00:00:00 2001 From: ailurux Date: Tue, 30 Jul 2024 04:36:48 +0000 Subject: daniel/playlist-queue (#84) Support for playlist files being opened along side the queue's own playlist. Playlists can be opened from the file browser, if the file ends in ".playlist" (will add support for .m3u as well eventually) Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/84 Co-authored-by: ailurux Co-committed-by: ailurux --- lua/file_browser.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index 91b84c84..aed4aef8 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -62,10 +62,14 @@ return screen:new{ if is_dir then backstack.push(require("file_browser"):new{ title = self.title, - iterator = filesystem.iterator(tostring(item)), - breadcrumb = tostring(item) + iterator = filesystem.iterator(item:filepath()), + breadcrumb = item:filepath() }) end + if item:filepath():match("%.playlist$") then + queue.open_playlist(item:filepath()) + backstack.push(playing:new()) + end end end }) -- cgit v1.2.3 From 2a280c9b4b3afdedf68f8b27b8ce8dad6ab9470f Mon Sep 17 00:00:00 2001 From: jacqueline Date: Tue, 30 Jul 2024 14:56:42 +1000 Subject: Start playback immediately when selecting a playlist --- lua/file_browser.lua | 121 ++++++++++++++++++++++++++------------------------- 1 file changed, 61 insertions(+), 60 deletions(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index aed4aef8..f4f6f216 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -10,68 +10,69 @@ local theme = require("theme") local screen = require("screen") local filesystem = require("filesystem") -return screen:new{ - createUi = function(self) - self.root = lvgl.Object(nil, { - flex = { - flex_direction = "column", - flex_wrap = "wrap", - justify_content = "flex-start", - align_items = "flex-start", - align_content = "flex-start" - }, - w = lvgl.HOR_RES(), - h = lvgl.VER_RES() - }) - self.root:center() +return screen:new { + createUi = function(self) + self.root = lvgl.Object(nil, { + flex = { + flex_direction = "column", + flex_wrap = "wrap", + justify_content = "flex-start", + align_items = "flex-start", + align_content = "flex-start" + }, + w = lvgl.HOR_RES(), + h = lvgl.VER_RES() + }) + self.root:center() - self.status_bar = widgets.StatusBar(self, { - back_cb = backstack.pop, - title = self.title - }) + self.status_bar = widgets.StatusBar(self, { + back_cb = backstack.pop, + title = self.title + }) - local header = self.root:Object{ - flex = { - flex_direction = "column", - flex_wrap = "wrap", - justify_content = "flex-start", - align_items = "flex-start", - align_content = "flex-start" - }, - w = lvgl.HOR_RES(), - h = lvgl.SIZE_CONTENT, - pad_left = 4, - pad_right = 4, - pad_bottom = 2, - bg_opa = lvgl.OPA(100), - scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF - } - theme.set_style(header, "header") + local header = self.root:Object { + flex = { + flex_direction = "column", + flex_wrap = "wrap", + justify_content = "flex-start", + align_items = "flex-start", + align_content = "flex-start" + }, + w = lvgl.HOR_RES(), + h = lvgl.SIZE_CONTENT, + pad_left = 4, + pad_right = 4, + pad_bottom = 2, + bg_opa = lvgl.OPA(100), + scrollbar_mode = lvgl.SCROLLBAR_MODE.OFF + } + theme.set_style(header, "header") - if self.breadcrumb then - header:Label{ - text = self.breadcrumb, - text_font = font.fusion_10 - } - end - - widgets.InfiniteList(self.root, self.iterator, { - callback = function(item) - return function() - local is_dir = item:is_directory() - if is_dir then - backstack.push(require("file_browser"):new{ - title = self.title, - iterator = filesystem.iterator(item:filepath()), - breadcrumb = item:filepath() - }) - end - if item:filepath():match("%.playlist$") then - queue.open_playlist(item:filepath()) - backstack.push(playing:new()) - end - end - end - }) + if self.breadcrumb then + header:Label { + text = self.breadcrumb, + text_font = font.fusion_10 + } end + + widgets.InfiniteList(self.root, self.iterator, { + callback = function(item) + return function() + local is_dir = item:is_directory() + if is_dir then + backstack.push(require("file_browser"):new { + title = self.title, + iterator = filesystem.iterator(item:filepath()), + breadcrumb = item:filepath() + }) + end + if item:filepath():match("%.playlist$") then + queue.open_playlist(item:filepath()) + playback.playing:set(true) + backstack.push(playing:new()) + end + end + end + }) + end } -- cgit v1.2.3 From 3421bd652c39b253872e43d3b6e43664bd0b66e2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 28 Aug 2024 15:30:53 +1000 Subject: When clicking a track in the file browser, play it Includes adding a `playback.is_playable` for working out whether or not a particular file is able to be played --- lua/file_browser.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index f4f6f216..08d683e1 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -65,11 +65,15 @@ return screen:new { iterator = filesystem.iterator(item:filepath()), breadcrumb = item:filepath() }) - end - if item:filepath():match("%.playlist$") then + elseif item:filepath():match("%.playlist$") then queue.open_playlist(item:filepath()) playback.playing:set(true) backstack.push(playing:new()) + elseif playback.is_playable(item:filepath()) then + queue.clear() + queue.add(item:filepath()) + playback.playing:set(true) + backstack.push(playing:new()) end end end -- cgit v1.2.3 From 91eaed4b37c7cda29103d3478df3e2c6356f8396 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 29 Aug 2024 15:52:34 +1000 Subject: use snake_case consistently in lua function names --- lua/file_browser.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index 08d683e1..b9c31d62 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -11,7 +11,7 @@ local screen = require("screen") local filesystem = require("filesystem") return screen:new { - createUi = function(self) + create_ui = function(self) self.root = lvgl.Object(nil, { flex = { flex_direction = "column", -- cgit v1.2.3 From 0426dfd4f21861297850905bf27158659f9d959a Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 6 Sep 2024 12:39:53 +1000 Subject: Support opening m3u and m3u8 files as playlists --- lua/file_browser.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index b9c31d62..a79cc7f0 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -65,7 +65,9 @@ return screen:new { iterator = filesystem.iterator(item:filepath()), breadcrumb = item:filepath() }) - elseif item:filepath():match("%.playlist$") then + elseif + item:filepath():match("%.playlist$") or + item:filepath():match("%.m3u$") then queue.open_playlist(item:filepath()) playback.playing:set(true) backstack.push(playing:new()) -- cgit v1.2.3 From d0f70787b1686adf48858b94b6187433659549c9 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 6 Sep 2024 12:41:49 +1000 Subject: m3u and m3u8 --- lua/file_browser.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lua/file_browser.lua') diff --git a/lua/file_browser.lua b/lua/file_browser.lua index a79cc7f0..0ccd2c13 100644 --- a/lua/file_browser.lua +++ b/lua/file_browser.lua @@ -67,7 +67,7 @@ return screen:new { }) elseif item:filepath():match("%.playlist$") or - item:filepath():match("%.m3u$") then + item:filepath():match("%.m3u8?$") then queue.open_playlist(item:filepath()) playback.playing:set(true) backstack.push(playing:new()) -- cgit v1.2.3