Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: J. Nick Koston <nick@koston.org>
27 lines
688 B
C++
27 lines
688 B
C++
#pragma once
|
|
|
|
#include "speaker_media_player.h"
|
|
|
|
#ifdef USE_ESP32
|
|
|
|
#include "esphome/components/audio/audio.h"
|
|
#include "esphome/core/automation.h"
|
|
|
|
namespace esphome {
|
|
namespace speaker {
|
|
|
|
template<typename... Ts> class PlayOnDeviceMediaAction : public Action<Ts...>, public Parented<SpeakerMediaPlayer> {
|
|
TEMPLATABLE_VALUE(audio::AudioFile *, audio_file)
|
|
TEMPLATABLE_VALUE(bool, announcement)
|
|
TEMPLATABLE_VALUE(bool, enqueue)
|
|
void play(const Ts &...x) override {
|
|
this->parent_->play_file(this->audio_file_.value(x...), this->announcement_.value(x...),
|
|
this->enqueue_.value(x...));
|
|
}
|
|
};
|
|
|
|
} // namespace speaker
|
|
} // namespace esphome
|
|
|
|
#endif
|