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 How to update Chromecast MediaMetadata during radio stream? - Stack Overflow (https://stackoverflow.com/questions/52087171/how-to-update-chromecast-mediametadata-during-radio-stream)