3#if defined(USE_ESP32) && defined(USE_SENDSPIN_CONTROLLER) && defined(USE_SENDSPIN_PLAYER)
12static const char *
const TAG =
"sendspin.media_source";
14static constexpr char URI_PREFIX[] =
"sendspin://";
19 ESP_LOGE(TAG,
"Failed to get player role from hub");
38 this->
player_role_->set_static_delay_adjustable(adjustable);
53 ESP_LOGE(TAG,
"Cannot play '%s': source is busy", uri.c_str());
57 if (!uri.starts_with(URI_PREFIX)) {
58 ESP_LOGE(TAG,
"Invalid URI: '%s'", uri.c_str());
62 std::string sendspin_id = uri.substr(
sizeof(URI_PREFIX) - 1);
64 if (sendspin_id.empty()) {
65 ESP_LOGE(TAG,
"Invalid URI: '%s'", uri.c_str());
69 ESP_LOGD(TAG,
"sendspin_id: %s", sendspin_id.c_str());
71 if (sendspin_id !=
"current") {
73 this->
parent_->connect_to_server(
"ws://" + sendspin_id);
90 ESP_LOGD(TAG,
"Received STOP command, updating Sendspin state to EXTERNAL_SOURCE");
91 this->
parent_->update_state(sendspin::SendspinClientState::EXTERNAL_SOURCE);
96 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PLAY, std::nullopt, std::nullopt);
99 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PAUSE, std::nullopt, std::nullopt);
102 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::NEXT, std::nullopt, std::nullopt);
105 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::PREVIOUS, std::nullopt, std::nullopt);
108 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ALL, std::nullopt, std::nullopt);
111 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_ONE, std::nullopt, std::nullopt);
114 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::REPEAT_OFF, std::nullopt, std::nullopt);
117 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::SHUFFLE, std::nullopt, std::nullopt);
120 this->
parent_->send_client_command(sendspin::SendspinControllerCommand::UNSHUFFLE, std::nullopt, std::nullopt);
131 this->
player_role_->update_volume(std::roundf(volume * 100.0f));
156 vTaskDelay(pdMS_TO_TICKS(timeout_ms));
161 auto ¶ms = this->
player_role_->get_current_stream_params();
162 if (!params.bit_depth.has_value() || !params.channels.has_value() || !params.sample_rate.has_value()) {
163 vTaskDelay(pdMS_TO_TICKS(timeout_ms));
173 this->
parent_->update_state(sendspin::SendspinClientState::SYNCHRONIZED);
void mark_failed()
Mark this component as failed.