diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-08-28 15:30:25 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-08-28 15:30:25 +1000 |
| commit | af7a70450e3ceaaf291aa09b9383b50b879759d9 (patch) | |
| tree | be024b6eb3373035407182efa41a6a587bb98a7d /src/tangara/lua/lua_queue.cpp | |
| parent | 9145722b08b9c648e41d6b36f83bebbd106efc1e (diff) | |
| download | tangara-fw-af7a70450e3ceaaf291aa09b9383b50b879759d9.tar.gz | |
Support adding filepaths to the track queue
Diffstat (limited to 'src/tangara/lua/lua_queue.cpp')
| -rw-r--r-- | src/tangara/lua/lua_queue.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/tangara/lua/lua_queue.cpp b/src/tangara/lua/lua_queue.cpp index 9e2002e6..7eb32c62 100644 --- a/src/tangara/lua/lua_queue.cpp +++ b/src/tangara/lua/lua_queue.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: GPL-3.0-only */ +#include "audio/audio_events.hpp" #include "lua/lua_database.hpp" #include <memory> @@ -39,6 +40,14 @@ static auto queue_add(lua_State* state) -> int { audio::TrackQueue& queue = instance->services().track_queue(); queue.append(id); }); + } else if (lua_isstring(state, 1)) { + size_t len; + const char* str = luaL_checklstring(state, 1, &len); + std::string path{str, len}; + instance->services().bg_worker().Dispatch<void>([=]() { + audio::TrackQueue& queue = instance->services().track_queue(); + queue.append(path); + }); } else { database::Iterator* it = db_check_iterator(state, 1); instance->services().bg_worker().Dispatch<void>([=]() { @@ -70,10 +79,11 @@ static auto queue_open_playlist(lua_State* state) -> int { return 0; } -static const struct luaL_Reg kQueueFuncs[] = {{"add", queue_add}, - {"clear", queue_clear}, - {"open_playlist", queue_open_playlist}, - {NULL, NULL}}; +static const struct luaL_Reg kQueueFuncs[] = { + {"add", queue_add}, + {"clear", queue_clear}, + {"open_playlist", queue_open_playlist}, + {NULL, NULL}}; static auto lua_queue(lua_State* state) -> int { luaL_newlib(state, kQueueFuncs); |
