Hide music player if it is not playing

I’m trying to hide a media player if it’s not playing anything. I’m using the following code, but without success.

type: media-control
entity: media_player.echo_show_8_2a_geracao_de_renato
card_mod:
  style: |
    :host {
      {% if is_state('media_player.echo_show_8_2a_geracao_de_renato','playing') %}
          service: homeassistant.unhide_entity
          data:
            entity_id: media_player.echo_show_8_2a_geracao_de_renato
              
        {% elif is_state('media_player.echo_show_8_2a_geracao_de_renato','standby') %}

          service: homeassistant.hide_entity
          data:
            entity_id: media_player.echo_show_8_2a_geracao_de_renato
        
      {% endif %}
    }

i try

type: media-control
entity: media_player.echo_show_8_2a_geracao_de_renato
card_mod:
  style: |
    :host {
      {% if is_state('media_player.echo_show_8_2a_geracao_de_renato','playing') %}
          service: homeassistant.unhide_entity
          data:
            entity_id: media_player.echo_show_8_2a_geracao_de_renato
              
         {% else %}

          service: homeassistant.hide_entity
          data:
            entity_id: media_player.echo_show_8_2a_geracao_de_renato
        
      {% endif %}
    }

resolved :smile:

type: conditional
conditions:
  - entity: media_player.echo_show_8_2a_geracao_de_renato
    state: playing
card:
  type: media-control
  entity: media_player.echo_show_8_2a_geracao_de_renato

Or using the visibility tab in the UI

      - type: media-control
        entity: media_player.lg_webos_tv_uh850v
        visibility:
          - condition: state
            entity: media_player.lg_webos_tv_uh850v
            state: playing