Pass by url the entity_picture attribute of a media player

Hi friends. I have several media_players objects and I want to know how to extract the images from those that are active. I tried to do it but I can only extract it on a tamplate.
I leave the code to see if they realize it since when translating the language out there it is not understood.

Hi friends. I have several media_players objects and I want to know how to extract the images from those that are active. I tried to do it but I can only extract it on a tamplate.
I leave the code to see if they realize it since when translating the language out there it is not understood.

(pass by url the entity_picture attribute of a media player)
Thank you

Thank you

  styles:
    custom_fields:
      media_image:
        - background-position: center center
        - background-image: >
            [[[                                          
              if(states['media_player.pablo_y_silvy'].state === 'playing') 
                return "url(" + {{state_attr('media_player.pablo_y_silvy', 'entity_picture')}} +")";
               else  
                return "url('/local/img/multimedia.jfif')";
            ]]] 

Testing a little I found how to do it

replace
return "url(" + {{state_attr('media_player.pablo_y_silvy', 'entity_picture')}} +")";
whith
return "url("+states['media_player.pablo_y_silvy'].attributes.entity_picture+")";

  styles:
    custom_fields:
      media_image:
        - background-position: center center
        - background-image: >
            [[[                        
              if(states['media_player.pablo_y_silvy'].state === 'playing') 
                return "url("+states['media_player.pablo_y_silvy'].attributes.entity_picture+")";
               else  
                return "url('/local/img/multimedia.jfif')";
            ]]] 
1 Like

Now. I have multiple media_player objects. Can you make the image display every two seconds of the players that are active?