summaryrefslogtreecommitdiff
path: root/src/ui/ui_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2023-12-08 11:11:57 +1100
committerjacqueline <me@jacqueline.id.au>2023-12-08 11:11:57 +1100
commitca5d7b867c381b7886a660ce744df0b74f38b2e6 (patch)
tree61987a625e63a124c142be3df2c8dde0d9c14613 /src/ui/ui_fsm.cpp
parentaaa949f71805e2040c7ee9a4d0a3c260de95a6d0 (diff)
downloadtangara-fw-ca5d7b867c381b7886a660ce744df0b74f38b2e6.tar.gz
Add shuffle and repeat options for the playback queue
Diffstat (limited to 'src/ui/ui_fsm.cpp')
-rw-r--r--src/ui/ui_fsm.cpp26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp
index 783494dd..f4b56a27 100644
--- a/src/ui/ui_fsm.cpp
+++ b/src/ui/ui_fsm.cpp
@@ -176,6 +176,8 @@ void Lua::entry() {
queue_position_ = std::make_shared<lua::Property>(0);
queue_size_ = std::make_shared<lua::Property>(0);
+ queue_repeat_ = std::make_shared<lua::Property>(false);
+ queue_random_ = std::make_shared<lua::Property>(false);
playback_playing_ = std::make_shared<lua::Property>(
false, [&](const lua::LuaValue& val) { return SetPlaying(val); });
@@ -203,6 +205,8 @@ void Lua::entry() {
sLua->bridge().AddPropertyModule("queue", {
{"position", queue_position_},
{"size", queue_size_},
+ {"replay", queue_repeat_},
+ {"random", queue_random_},
});
sLua->bridge().AddPropertyModule(
"backstack",
@@ -242,7 +246,7 @@ auto Lua::PushLuaScreen(lua_State* s) -> int {
return 0;
}
-auto Lua::PopLuaScreen(lua_State *s) -> int {
+auto Lua::PopLuaScreen(lua_State* s) -> int {
PopScreen();
luavgl_set_root(s, sCurrentScreen->content());
lv_group_set_default(sCurrentScreen->group());
@@ -261,6 +265,24 @@ auto Lua::SetPlaying(const lua::LuaValue& val) -> bool {
return true;
}
+auto Lua::SetRandom(const lua::LuaValue& val) -> bool {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool b = std::get<bool>(val);
+ sServices->track_queue().random(b);
+ return true;
+}
+
+auto Lua::SetRepeat(const lua::LuaValue& val) -> bool {
+ if (!std::holds_alternative<bool>(val)) {
+ return false;
+ }
+ bool b = std::get<bool>(val);
+ sServices->track_queue().repeat(b);
+ return true;
+}
+
void Lua::exit() {
lv_group_set_default(NULL);
}
@@ -288,6 +310,8 @@ void Lua::react(const audio::QueueUpdate&) {
current_pos++;
}
queue_position_->Update(current_pos);
+ queue_random_->Update(queue.random());
+ queue_repeat_->Update(queue.repeat());
}
void Lua::react(const audio::PlaybackStarted& ev) {