Update media metadata displayed on Chromecast

Hi,

I’m using HA to launch a webradio on my Chromecast. I do it by calling a script from a button (picture cards in a grid) :

type: grid
cards:
  - type: picture
    tap_action:
      action: call-service
      service: script.switch_radio
      service_data:
        url: 'http://radiofg.impek.com/ufg.mp3'
        volume: 0.8
        radio_name: FG Avant-Garde
        radio_icon: 'https://cdn-profiles.tunein.com/s54467/images/logoq.png?t=160880'
    hold_action:
      action: none
    image: 'https://cdn-profiles.tunein.com/s54467/images/logoq.png?t=160880'

And my script is simply:

switch_radio:
  alias: Play Radio on Chromecast from buttons
  sequence:
  - service: media_player.volume_set
    data_template:
      entity_id: media_player.chromecast
      volume_level: '{{ volume }}'
  - service: media_player.play_media
    data_template:
      entity_id: media_player.chromecast
      media_content_id: '{{ url }}'
      media_content_type: audio/mp4
      extra:
        thumb: '{{ radio_icon }}'
        title: '{{ radio_name }}'
  mode: single

It works great, and display the name of the radio as well as the radio icon on the Chromecast Default Media player. so far so good.

Now I’d like to also display some more metadata on the Chromecast screen.

I’ve found out I can use curl to obtain the track title being played by the webradio using :

$ curl -s 'https://feed.tunein.com/profiles/s54467/nowPlaying' | jq .Header.Subtitle
"Visions Of You - Jpa"

I could create a sensor that periodically query for the song title, but my question is:

how can I update the metadata of the media to the Chromecast? Any idea?

I can set the metadata (see MusicTrackMediaMetadata), when I first call the media_player.play_media service (when running the script), for example:

entity_id: media_player.chromecast
media_content_id: 'http://radiofg.impek.com/ufg.mp3'
media_content_type: audio/mp4
extra:
  title: 'Title'
  metadata:
    metadataType: 3
    albumName: "albumName"
    artist: "artist"

but that will shortly interrupt the sound feed. it’s actually reconnecting the Chromecast to a new feed… (even if it’s the same one).

Do you know a way to only update the metadata shown on screen? like pushing just a metadata update? (via HA or any other way, I could code it or use maybe Node-Red…).

Thanks in advance

Edit: apparently I’m not the only one looking for this, but nobody seems to find a way… Maybe there isn’t any :frowning: How to update Chromecast MediaMetadata during radio stream? - Stack Overflow (https://stackoverflow.com/questions/52087171/how-to-update-chromecast-mediametadata-during-radio-stream)

2 Likes

I read everything you are doing and it’s exactly the same as myself, I also cannot show meta data, I have it displaying in VLC, but not in HA

I very much doubt there is a way. The Chromecast (and indeed any media player) - expects either that the metadata is provided at the start before it loads the stream, or that the metadata is included in the stream it is playing, in the case of anything streaming.

Hi, is quite old this thread but only know I’m hitting this issue and I’m still digging on this problem.
so here are my findings.
I have a google nest speaker integrated in HA and I noticed that if I’m playing a radio from HA the art work is not quite where I want to be. But when I asked google to play a radio on that speaker the player in HA looks perfect, with art work current playing info and so on. So I went to development tools>states there you can see attribute, when I asked google to play kissFM, I think you should focus on media_* tags:

volume_level: 0.30000001192092896
is_volume_muted: false
media_content_id: https://live.kissfm.ro/kissfm.aacp
media_content_type: music
media_position: 1.521732
media_position_updated_at: 2023-03-05T18:08:13.364782+00:00
media_title: Hit Hit in the Mix - Boba & Jonnessey
media_artist: Kiss FM Romania
app_id: 12F05308
app_name: TuneIn Free
entity_picture_local: /api/media_player_proxy/media_player.nestmini5343?token=65f00bdc9c56c66fbc9a2be462128e0d66dc6902a1378498ab5a43b7e7a5c8f5&cache=e71943cde6329686
device_class: speaker
entity_picture: https://cdn-profiles.tunein.com/p1027103/images/logoq.jpg?t=158897
friendly_name: Living Room speaker
supported_features: 152461

I posted a solution here: