From 2f16d230025c3173cfbecc58b38d6a52b6b0f5f2 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 5 Jul 2023 20:09:03 +1000 Subject: Start on wiring up playback screen to real data --- src/ui/include/screen_playing.hpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/ui/include/screen_playing.hpp') diff --git a/src/ui/include/screen_playing.hpp b/src/ui/include/screen_playing.hpp index 3eae32a7..5ccfe391 100644 --- a/src/ui/include/screen_playing.hpp +++ b/src/ui/include/screen_playing.hpp @@ -6,12 +6,15 @@ #pragma once +#include #include +#include #include "lvgl.h" #include "database.hpp" #include "screen.hpp" +#include "track.hpp" namespace ui { namespace screens { @@ -23,6 +26,9 @@ class Playing : public Screen { auto BindTrack(database::Track t) -> void; + auto UpdateTime(uint32_t) -> void; + auto UpdateNextUp(std::vector tracks) -> void; + private: database::Track track_; @@ -34,6 +40,7 @@ class Playing : public Screen { lv_obj_t* play_pause_control_; lv_obj_t* next_up_container_; + std::vector next_tracks_; }; } // namespace screens -- cgit v1.2.3 From 39f7545cd5ef7a30bbd482f3579df7744c6b688d Mon Sep 17 00:00:00 2001 From: jacqueline Date: Fri, 7 Jul 2023 15:29:47 +1000 Subject: wire up the playing screen with some real data Includes implementing song duration calculation for CBR MP3 files --- src/ui/include/screen_playing.hpp | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) (limited to 'src/ui/include/screen_playing.hpp') diff --git a/src/ui/include/screen_playing.hpp b/src/ui/include/screen_playing.hpp index 5ccfe391..148f2774 100644 --- a/src/ui/include/screen_playing.hpp +++ b/src/ui/include/screen_playing.hpp @@ -7,30 +7,54 @@ #pragma once #include +#include #include #include #include "lvgl.h" #include "database.hpp" +#include "future_fetcher.hpp" #include "screen.hpp" #include "track.hpp" +#include "track_queue.hpp" namespace ui { namespace screens { +/* + * The 'Now Playing' / 'Currently Playing' screen that contains information + * about the current track, as well as playback controls. + */ class Playing : public Screen { public: - explicit Playing(database::Track t); + explicit Playing(std::weak_ptr db, + audio::TrackQueue* queue); ~Playing(); - auto BindTrack(database::Track t) -> void; + auto Tick() -> void override; - auto UpdateTime(uint32_t) -> void; - auto UpdateNextUp(std::vector tracks) -> void; + // Callbacks invoked by the UI state machine in response to audio events. + + auto OnTrackUpdate() -> void; + auto OnPlaybackUpdate(uint32_t, uint32_t) -> void; + auto OnQueueUpdate() -> void; private: - database::Track track_; + auto BindTrack(const database::Track& track) -> void; + auto ApplyNextUp(const std::vector& tracks) -> void; + + std::weak_ptr db_; + audio::TrackQueue* queue_; + + std::optional track_; + std::vector next_tracks_; + + std::unique_ptr>> + new_track_; + std::unique_ptr< + database::FutureFetcher>>> + new_next_tracks_; lv_obj_t* artist_label_; lv_obj_t* album_label_; @@ -40,7 +64,6 @@ class Playing : public Screen { lv_obj_t* play_pause_control_; lv_obj_t* next_up_container_; - std::vector next_tracks_; }; } // namespace screens -- cgit v1.2.3