diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-11-25 08:51:14 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-11-25 08:51:14 +1100 |
| commit | e6844a68b61477d1c0a1d225d75c04c7e6678495 (patch) | |
| tree | c3b81ab0f5d540edddf39ea62d8786942bc799b2 /src/ui/ui_fsm.cpp | |
| parent | f3e4210f24fe27701d29f0ab0735333202622a89 (diff) | |
| download | tangara-fw-e6844a68b61477d1c0a1d225d75c04c7e6678495.tar.gz | |
implement play/pause
Diffstat (limited to 'src/ui/ui_fsm.cpp')
| -rw-r--r-- | src/ui/ui_fsm.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ui/ui_fsm.cpp b/src/ui/ui_fsm.cpp index 557dc1a3..539cbc9b 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -7,6 +7,7 @@ #include "ui_fsm.hpp" #include <memory> +#include <variant> #include "lua.h" #include "lua.hpp" @@ -179,7 +180,8 @@ void Lua::entry() { queue_position_ = std::make_shared<lua::Property>(0); queue_size_ = std::make_shared<lua::Property>(0); - playback_playing_ = std::make_shared<lua::Property>(false); + playback_playing_ = std::make_shared<lua::Property>( + false, [&](const lua::LuaValue& val) { return SetPlaying(val); }); playback_track_ = std::make_shared<lua::Property>(); playback_position_ = std::make_shared<lua::Property>(); @@ -250,6 +252,18 @@ auto Lua::PopLuaScreen(lua_State* s) -> int { return 0; } +auto Lua::SetPlaying(const lua::LuaValue& val) -> bool { + bool current_val = std::get<bool>(playback_playing_->Get()); + if (!std::holds_alternative<bool>(val)) { + return false; + } + bool new_val = std::get<bool>(val); + if (current_val != new_val) { + events::Audio().Dispatch(audio::TogglePlayPause{}); + } + return true; +} + void Lua::exit() { lv_group_set_default(NULL); } |
