3#if defined(USE_ESP_IDF) && defined(USE_SENDSPIN_CONTROLLER) && defined(USE_SENDSPIN_PLAYER)
14static constexpr char URI_PREFIX[] =
"sendspin://";
19 ESP_LOGE(TAG,
"Failed to get player role from hub");
38 this->
player_role_->set_output_delay_adjustable(adjustable);
55 ESP_LOGE(TAG,
"Cannot play '%s': source is busy", uri.c_str());
59 if (!this->
parent_->is_client_running()) {
60 ESP_LOGE(TAG,
"Cannot play '%s': Sendspin is disabled", uri.c_str());
64 if (!uri.starts_with(URI_PREFIX)) {
65 ESP_LOGE(TAG,
"Invalid URI: '%s'", uri.c_str());
69 std::string sendspin_id = uri.substr(
sizeof(URI_PREFIX) - 1);
71 if (sendspin_id.empty()) {
72 ESP_LOGE(TAG,
"Invalid URI: '%s'", uri.c_str());
76 ESP_LOGD(TAG,
"sendspin_id: %s", sendspin_id.c_str());
78 if (sendspin_id !=
"current") {
80 this->
parent_->connect_to_server(
"ws://" + sendspin_id);
91 if (!this->
parent_->is_client_running()) {
96 ESP_LOGW(TAG,
"Cannot handle command: Sendspin is disabled");
105 ESP_LOGD(TAG,
"Received STOP command, leaving the Sendspin group");
111 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PLAY, std::nullopt, std::nullopt);
114 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PAUSE, std::nullopt, std::nullopt);
117 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::NEXT, std::nullopt, std::nullopt);
120 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PREVIOUS, std::nullopt, std::nullopt);
123 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ALL, std::nullopt, std::nullopt);
126 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ONE, std::nullopt, std::nullopt);
129 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_OFF, std::nullopt, std::nullopt);
132 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::SHUFFLE, std::nullopt, std::nullopt);
135 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::UNSHUFFLE, std::nullopt, std::nullopt);
146 this->
player_role_->update_volume(std::roundf(volume * 100.0f));
171 vTaskDelay(pdMS_TO_TICKS(timeout_ms));
176 auto ¶ms = this->
player_role_->get_current_stream_params();
177 if (!params.bit_depth.has_value() || !params.channels.has_value() || !params.sample_rate.has_value()) {
178 vTaskDelay(pdMS_TO_TICKS(timeout_ms));
void mark_failed()
Mark this component as failed.
ESPHOME_LOG_TAG(TAG, "sendspin.image")