summaryrefslogtreecommitdiff
path: root/src/tangara/ui/ui_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-08-28 15:30:53 +1000
committerjacqueline <me@jacqueline.id.au>2024-08-28 15:30:53 +1000
commit3421bd652c39b253872e43d3b6e43664bd0b66e2 (patch)
tree90a6cc3980e32648b8488db281dc838e3ffbdd7d /src/tangara/ui/ui_fsm.cpp
parentaf7a70450e3ceaaf291aa09b9383b50b879759d9 (diff)
downloadtangara-fw-3421bd652c39b253872e43d3b6e43664bd0b66e2.tar.gz
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
Diffstat (limited to 'src/tangara/ui/ui_fsm.cpp')
-rw-r--r--src/tangara/ui/ui_fsm.cpp26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/tangara/ui/ui_fsm.cpp b/src/tangara/ui/ui_fsm.cpp
index a20eb0ef..94d1caf8 100644
--- a/src/tangara/ui/ui_fsm.cpp
+++ b/src/tangara/ui/ui_fsm.cpp
@@ -15,6 +15,8 @@
#include "FreeRTOSConfig.h"
#include "draw/lv_draw_buf.h"
#include "drivers/bluetooth.hpp"
+#include "lauxlib.h"
+#include "lua.h"
#include "lvgl.h"
#include "core/lv_group.h"
@@ -609,11 +611,25 @@ void Lua::entry() {
{"discovered_devices", &sBluetoothDiscoveredDevices},
{"known_devices", &sBluetoothKnownDevices},
});
- registry.AddPropertyModule("playback", {
- {"playing", &sPlaybackPlaying},
- {"track", &sPlaybackTrack},
- {"position", &sPlaybackPosition},
- });
+ registry.AddPropertyModule(
+ "playback",
+ {
+ {"playing", &sPlaybackPlaying},
+ {"track", &sPlaybackTrack},
+ {"position", &sPlaybackPosition},
+ {"is_playable",
+ [&](lua_State* s) {
+ size_t len;
+ const char* path = luaL_checklstring(s, 1, &len);
+ auto res = sServices->tag_parser().ReadAndParseTags({path, len});
+ if (res) {
+ lua_pushboolean(s, true);
+ } else {
+ lua_pushboolean(s, false);
+ }
+ return 1;
+ }},
+ });
registry.AddPropertyModule(
"queue",
{