8 namespace media_player {
10 #define MEDIA_PLAYER_SIMPLE_COMMAND_ACTION(ACTION_CLASS, ACTION_COMMAND) \ 11 template<typename... Ts> class ACTION_CLASS : public Action<Ts...>, public Parented<MediaPlayer> { \ 12 void play(Ts... x) override { \ 13 this->parent_->make_call().set_command(MediaPlayerCommand::MEDIA_PLAYER_COMMAND_##ACTION_COMMAND).perform(); \ 17 #define MEDIA_PLAYER_SIMPLE_STATE_TRIGGER(TRIGGER_CLASS, TRIGGER_STATE) \ 18 class TRIGGER_CLASS : public Trigger<> { \ 20 explicit TRIGGER_CLASS(MediaPlayer *player) { \ 21 player->add_on_state_callback([this, player]() { \ 22 if (player->state == MediaPlayerState::MEDIA_PLAYER_STATE_##TRIGGER_STATE) \ 36 TEMPLATABLE_VALUE(std::string, media_url)
41 TEMPLATABLE_VALUE(
float, volume)
42 void play(Ts...
x)
override { this->
parent_->make_call().set_volume(this->volume_.value(
x...)).perform(); }
Base class for all automation conditions.
virtual void play(Ts... x)=0
Helper class to easily give an object a parent of type T.