Plumb queue next+previous through to Lua, incl. with stubs and docs.

custom
Robin Howard 1 year ago committed by Robin Howard
parent 9b63f14cb8
commit 3f1fadbeef
  1. 6
      ldoc-stubs/queue.lua
  2. 3
      luals-stubs/queue.lua
  3. 3
      src/ui/include/ui_fsm.hpp
  4. 26
      src/ui/ui_fsm.cpp

@ -19,4 +19,10 @@ queue.replay = types.Property
-- @see types.Property -- @see types.Property
queue.random = types.Property queue.random = types.Property
--- Moves forward in the play queue, looping back around to the beginning if repeat is on.
function queue.next() end
--- Moves backward in the play queue, looping back around to the end if repeat is on.
function queue.previous() end
return queue return queue

@ -8,4 +8,7 @@
--- @field random Property Determines whether, when progressing to the next track in the queue, the next track will be chosen randomly. The random selection algorithm used is a Miller Shuffle, which guarantees that no repeat selections will be made until every item in the queue has been played. Writeable. --- @field random Property Determines whether, when progressing to the next track in the queue, the next track will be chosen randomly. The random selection algorithm used is a Miller Shuffle, which guarantees that no repeat selections will be made until every item in the queue has been played. Writeable.
local queue = {} local queue = {}
function queue.next() end
function queue.previous() end
return queue return queue

@ -164,6 +164,9 @@ class Lua : public UiState {
auto SetPlaying(const lua::LuaValue&) -> bool; auto SetPlaying(const lua::LuaValue&) -> bool;
auto SetRandom(const lua::LuaValue&) -> bool; auto SetRandom(const lua::LuaValue&) -> bool;
auto SetRepeat(const lua::LuaValue&) -> bool; auto SetRepeat(const lua::LuaValue&) -> bool;
auto QueueNext(lua_State*) -> int;
auto QueuePrevious(lua_State*) -> int;
}; };
} // namespace states } // namespace states

@ -396,12 +396,16 @@ void Lua::entry() {
{"track", &sPlaybackTrack}, {"track", &sPlaybackTrack},
{"position", &sPlaybackPosition}, {"position", &sPlaybackPosition},
}); });
sLua->bridge().AddPropertyModule("queue", { sLua->bridge().AddPropertyModule(
{"position", &sQueuePosition}, "queue",
{"size", &sQueueSize}, {
{"replay", &sQueueRepeat}, {"next", [&](lua_State* s) { return QueueNext(s); }},
{"random", &sQueueRandom}, {"previous", [&](lua_State* s) { return QueuePrevious(s); }},
}); {"position", &sQueuePosition},
{"size", &sQueueSize},
{"replay", &sQueueRepeat},
{"random", &sQueueRandom},
});
sLua->bridge().AddPropertyModule("volume", sLua->bridge().AddPropertyModule("volume",
{ {
{"current_pct", &sVolumeCurrentPct}, {"current_pct", &sVolumeCurrentPct},
@ -476,6 +480,16 @@ auto Lua::PushLuaScreen(lua_State* s) -> int {
return 0; return 0;
} }
auto Lua::QueueNext(lua_State*) -> int {
sServices->track_queue().next();
return 0;
}
auto Lua::QueuePrevious(lua_State*) -> int {
sServices->track_queue().previous();
return 0;
}
auto Lua::PopLuaScreen(lua_State* s) -> int { auto Lua::PopLuaScreen(lua_State* s) -> int {
PopScreen(); PopScreen();
luavgl_set_root(s, sCurrentScreen->content()); luavgl_set_root(s, sCurrentScreen->content());

Loading…
Cancel
Save