12#include <sendspin/client.h>
13#include <sendspin/config.h>
14#include <sendspin/types.h>
16#ifdef USE_SENDSPIN_CONTROLLER
17#include <sendspin/controller_role.h>
19#ifdef USE_SENDSPIN_METADATA
20#include <sendspin/metadata_role.h>
22#ifdef USE_SENDSPIN_PLAYER
23#include <sendspin/player_role.h>
37namespace sendspin_priority {
49#ifdef USE_SENDSPIN_PLAYER
72#ifdef USE_SENDSPIN_CONTROLLER
73 public sendspin::ControllerRoleListener,
75#ifdef USE_SENDSPIN_METADATA
76 public sendspin::MetadataRoleListener,
78 public sendspin::SendspinClientListener,
79 public sendspin::SendspinNetworkProvider,
80 public sendspin::SendspinPersistenceProvider {
83 void setup()
override;
124#ifdef USE_SENDSPIN_CONTROLLER
125 void send_client_command(sendspin::SendspinControllerCommand command, std::optional<uint8_t> volume = std::nullopt,
126 std::optional<bool> mute = std::nullopt);
133#ifdef USE_SENDSPIN_METADATA
142#ifdef USE_SENDSPIN_PLAYER
159 void on_group_update(
const sendspin::GroupUpdateObject &group)
override;
174#ifdef USE_SENDSPIN_CONTROLLER
183#ifdef USE_SENDSPIN_METADATA
186 void on_metadata(
const sendspin::ServerMetadataStateObject &metadata)
override;
192#ifdef USE_SENDSPIN_PLAYER
206 std::unique_ptr<sendspin::SendspinClient>
client_;
Helper class to easily give an object a parent of type T.
This class simplifies creating components that periodically check a state.
Base class for all sendspin subcomponents.
float get_setup_priority() const override
Thin adapter over sendspin::SendspinClient.
sendspin::PlayerRoleListener * player_listener_
void update_state(sendspin::SendspinClientState state)
Updates the client's reported playback state on the server.
bool save_last_server_hash(uint32_t hash) override
bool save_static_delay(uint16_t delay_ms) override
CallbackManager< void(const sendspin::ServerMetadataStateObject &)> metadata_update_callbacks_
CallbackManager< void(const sendspin::ServerStateControllerObject &)> controller_state_callbacks_
static const char * get_client_id_into_buffer(std::span< char, MAC_ADDRESS_PRETTY_BUFFER_SIZE > buf)
Writes the active network interface's MAC into buf and returns its data pointer.
void add_group_update_callback(F &&callback)
void on_release_high_performance() override
bool is_network_ready() override
sendspin::MetadataRole * metadata_role_
CallbackManager< void(const sendspin::GroupUpdateObject &)> group_update_callbacks_
sendspin::PlayerRoleConfig player_config_
void on_metadata(const sendspin::ServerMetadataStateObject &metadata) override
void set_player_config(const sendspin::PlayerRoleConfig &config)
void dump_config() override
sendspin::PlayerRole * get_player_role()
Child components call this to get the PlayerRole instance after setup, so they can push updates to it...
void set_listener(sendspin::PlayerRoleListener *listener)
void disconnect_from_server(sendspin::SendspinGoodbyeReason reason)
Disconnects the underlying client from the current server.
std::optional< uint16_t > load_static_delay() override
std::unique_ptr< sendspin::SendspinClient > client_
sendspin::SendspinClientConfig build_client_config_()
Builds the SendspinClientConfig from ESPHome configuration and platform info.
sendspin::ControllerRole * controller_role_
ESPPreferenceObject last_played_server_pref_
bool task_stack_in_psram_
uint32_t get_track_progress_ms() const
Returns the interpolated track progress in milliseconds, or 0 if the hub is not yet ready.
void add_controller_state_callback(F &&callback)
void send_client_command(sendspin::SendspinControllerCommand command, std::optional< uint8_t > volume=std::nullopt, std::optional< bool > mute=std::nullopt)
ESPPreferenceObject static_delay_pref_
void set_task_stack_in_psram(bool task_stack_in_psram)
void on_request_high_performance() override
float get_setup_priority() const override
std::optional< uint32_t > load_last_server_hash() override
void on_controller_state(const sendspin::ServerStateControllerObject &state) override
void connect_to_server(const std::string &url)
Connects the underlying client to the given Sendspin server.
void on_group_update(const sendspin::GroupUpdateObject &group) override
void add_metadata_update_callback(F &&callback)
Base class for sendspin subcomponents that need polling behavior.
float get_setup_priority() const override
constexpr float AFTER_WIFI
For components that should be initialized after WiFi is connected.
Persistent storage structure for last played server hash.
Persistent storage structure for player static delay.