diff options
| author | ailurux <ailurux@noreply.codeberg.org> | 2024-02-29 05:23:33 +0000 |
|---|---|---|
| committer | ailurux <ailurux@noreply.codeberg.org> | 2024-02-29 05:23:33 +0000 |
| commit | aa87c13799f5d71773b7c73135006acb592182d0 (patch) | |
| tree | 3c6ef26e5a00eecb0e4319377b4bccd71235e9ac /src/ui/ui_fsm.cpp | |
| parent | 173b09b0151ae765b1a8e69dfb60d14d502801f6 (diff) | |
| parent | e7e6c70fb31d33ae1e79f9841f5b6fe227f6ebf3 (diff) | |
| download | tangara-fw-aa87c13799f5d71773b7c73135006acb592182d0.tar.gz | |
Merge pull request 'Add seeking support for all codecs' (#50) from seek-support into main
Reviewed-on: https://codeberg.org/cool-tech-zone/tangara-fw/pulls/50
Reviewed-by: ailurux <ailurux@noreply.codeberg.org>
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 f5288882..d98e435d 100644 --- a/src/ui/ui_fsm.cpp +++ b/src/ui/ui_fsm.cpp @@ -125,7 +125,21 @@ lua::Property UiState::sPlaybackPlaying{ }}; lua::Property UiState::sPlaybackTrack{}; -lua::Property UiState::sPlaybackPosition{0}; +lua::Property UiState::sPlaybackPosition{0, [](const lua::LuaValue& val) { + int current_val = std::get<int>(sPlaybackPosition.Get()); + if (!std::holds_alternative<int>(val)) { + return false; + } + int new_val = std::get<int>(val); + if (current_val != new_val) { + auto track = sPlaybackTrack.Get(); + if (!std::holds_alternative<audio::Track>(track)) { + return false; + } + events::Audio().Dispatch(audio::SeekFile{.offset = (uint32_t)new_val, .filename = std::get<audio::Track>(track).filepath}); + } + return true; +}}; lua::Property UiState::sQueuePosition{0}; lua::Property UiState::sQueueSize{0}; |
