25 this->
parent_->add_group_update_callback([
this](
const sendspin::GroupUpdateObject &group_obj) {
26 if (group_obj.playback_state.has_value()) {
28 switch (group_obj.playback_state.value()) {
29 case sendspin::SendspinPlaybackState::PLAYING:
32 case sendspin::SendspinPlaybackState::STOPPED:
37 if (this->
state != new_state) {
38 this->
state = new_state;
45 this->
parent_->add_controller_state_callback([
this](
const sendspin::ServerStateControllerObject &
state) {
46 float new_volume =
static_cast<float>(
state.volume) / 100.0f;
47 bool new_muted =
state.muted;
48 if ((new_volume != this->
volume) || (new_muted != this->
muted_)) {
91 uint8_t new_volume =
static_cast<uint8_t
>(std::roundf(
volume.value() * 100.0f));
92 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::VOLUME, new_volume, std::nullopt);
95 auto command =
call.get_command();
96 if (!command.has_value()) {
99 switch (command.value()) {
102 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PAUSE);
104 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PLAY);
108 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PLAY);
111 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PAUSE);
114 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::STOP);
117 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_OFF);
120 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ONE);
123 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ALL);
126 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::SHUFFLE);
129 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::UNSHUFFLE);
132 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::NEXT);
135 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PREVIOUS);
138 this->
parent_->send_client_command(
139 sendspin::SendspinControllerCommand::VOLUME,
144 this->
parent_->send_client_command(
145 sendspin::SendspinControllerCommand::VOLUME,
150 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::MUTE, std::nullopt,
true);
153 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::MUTE, std::nullopt,
false);