46static const uint32_t MEDIA_CONTROLS_QUEUE_LENGTH = 20;
48static const UBaseType_t MEDIA_PIPELINE_TASK_PRIORITY = 1;
49static const UBaseType_t ANNOUNCEMENT_PIPELINE_TASK_PRIORITY = 1;
51static const char *
const TAG =
"speaker_media_player";
61 if (this->
pref_.
load(&volume_restore_state)) {
69#ifdef USE_OTA_STATE_LISTENER
75 ANNOUNCEMENT_PIPELINE_TASK_PRIORITY);
78 ESP_LOGE(TAG,
"Failed to create announcement pipeline");
87 ESP_LOGE(TAG,
"Failed to create media pipeline");
92 ESP_LOGI(TAG,
"Set up speaker media player");
96 switch (pipeline_type) {
136 if (media_command.
file.has_value()) {
137 playlist_item.
file = media_command.
file.value();
145 if (media_command.
file.has_value()) {
164 if (media_command.
file.has_value()) {
286#ifdef USE_OTA_STATE_LISTENER
319 ESP_LOGE(TAG,
"The media pipeline's file reader encountered an error.");
321 ESP_LOGE(TAG,
"The media pipeline's audio decoder encountered an error.");
330 ESP_LOGE(TAG,
"The announcement pipeline's file reader encountered an error.");
332 ESP_LOGE(TAG,
"The announcement pipeline's audio decoder encountered an error.");
339 uint32_t timeout_ms = 0;
355 }
else if (playlist_item.
file.has_value()) {
359 if (timeout_ms > 0) {
374 uint32_t timeout_ms = 0;
388 }
else if (playlist_item.
file.has_value()) {
392 if (timeout_ms > 0) {
408 if (this->
state != old_state) {
422 media_command.
file = media_file;
428 media_command.
enqueue = enqueue;
446 if (
call.get_media_url().has_value()) {
447 media_command.
url =
new std::string(
448 call.get_media_url().value());
450 if (
call.get_command().has_value()) {
460 if (
call.get_volume().has_value()) {
467 if (
call.get_command().has_value()) {
469 TickType_t ticks_to_wait = portMAX_DELAY;
482 traits.set_supports_pause(
true);
489 traits.get_supported_formats().push_back(this->
media_format_.value());
494 traits.get_supported_formats().push_back(media_format);
520 if (old_mute_state != mute_state) {
547 if (volume < 0.001) {
virtual void mark_failed()
Mark this component as failed.
ESPDEPRECATED("Use const char* overload instead. Removed in 2026.7.0", "2026.1.0") void defer(const std voi defer)(const char *name, std::function< void()> &&f)
Defer a callback to the next loop() call.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_timeout(const std voi set_timeout)(const char *name, uint32_t timeout, std::function< void()> &&f)
Set a timeout function with a unique name.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") void set_interval(const std voi set_interval)(const char *name, uint32_t interval, std::function< void()> &&f)
Set an interval function with a unique name.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_timeout(const std boo cancel_timeout)(const char *name)
Cancel a timeout function.
ESPDEPRECATED("Use const char* or uint32_t overload instead. Removed in 2026.7.0", "2026.1.0") bool cancel_interval(const std boo cancel_interval)(const char *name)
Cancel an interval function.
ESPPreferenceObject make_entity_preference(uint32_t version=0)
Create a preference object for storing this entity's state/settings.
void trigger(const Ts &...x)
Inform the parent automation that the event has triggered.
value_type const & value() const
void add_global_state_listener(OTAGlobalStateListener *listener)
virtual void set_volume(float volume)
virtual void set_mute_state(bool mute_state)
OTAGlobalCallback * get_global_ota_callback()
Providing packet encoding functions for exchanging data with a remote host.
T remap(U value, U min, U max, T min_out, T max_out)
Remap value from the range (min, max) to (min_out, max_out).
optional< std::string > url
optional< audio::AudioFile * > file