music-assistant / hass-music-assistant

Turn your Home Assistant instance into a jukebox, hassle free streaming of your favorite media to Home Assistant media players.
Apache License 2.0
1.36k stars 52 forks source link

Full meta data not displaying in HA media player entity #1635

Closed drosner closed 10 months ago

drosner commented 11 months ago

What version of Music Assistant has the issue?

2023.6.0b6

The problem

Using a LinkPlay device through the Dlna player to play TuneIn radio streams. Within the MA add on interface I see the artist, album, and track name playing. When I look at the corresponding HA media player entity in HA developer tool I don’t see any of that meta data nor does any of my media cards render this meta data. With tidal and Spotify all of this meta data does display and shows up as state variables in the media player entity.

So it seems the meta data is making its way from the source (TuneIn) to the MA server if it’s being displayed within the add on UI. Seems that meta data isn’t being mapped to the HA media player entity when the source is TuneIn but it does work for Tidal and Spotify?

How to reproduce

Stream anything from tune in using a Dlna device and confirm you can see artist, track, album from within the add on UI. Then go to developer tools and review state variables for the corresponding HA media player entity and you will not see those meta data in any state attributes.

Do same using tidal or Spotify and confirm that meta data does show up in both places.

Relevant log output

No response

Additional information

No response

What version of Home Assistant Core are your running

2023.11.2

What type of installation are you running?

Home Assistant OS

On what type of hardware are you running?

Raspberry Pi

OzGav commented 11 months ago

DLNA is a poorly standardised protocol. Do you have any other device types? If so, does that all work ok?

drosner commented 11 months ago

Let me try same device but it's AirPlay version and see...

melwinek commented 10 months ago

I confirm. I also don't have meta data via Slimproto. s1 s2 s3

OzGav commented 10 months ago

I confirm. I also don't have meta data via Slimproto.

What do you expect to see?

melwinek commented 10 months ago

What do you expect to see? The name and author of the song currently playing on radio. 291202755-fd2b64c3-95d8-4c57-ab38-67c907a318d3~2

OzGav commented 10 months ago

Is this using TuneIn?

melwinek commented 10 months ago

TuneIn and RadioBrowser.

OzGav commented 10 months ago

Ok thanks. This will be looked at in due course

drosner commented 10 months ago

My issue is also while using TuneIn and Tidal. If you'd like some help i'd be happy to help in any way including doing some actual development/testing if needed.

On Tue, Dec 19, 2023 at 1:05 AM melwinek @.***> wrote:

TuneIn and RadioBrowser.

— Reply to this email directly, view it on GitHub https://github.com/music-assistant/hass-music-assistant/issues/1635#issuecomment-1862176671, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHX7FNQGVFR3M5PL3AAUYJLYKEVCHAVCNFSM6AAAAAA7L3NQV6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNRSGE3TMNRXGE . You are receiving this because you authored the thread.Message ID: @.***>

OzGav commented 10 months ago

Sure the project is all open source. Marcel is always happy for PRs

marcelveldt commented 10 months ago

next beta will include a stream_title attribute for this

OzGav commented 10 months ago

Please report if this still an issue after beta79 is released

melwinek commented 10 months ago

The stream_title attribute is visible in developers tools/states. But it is not visible on the card. Maybe the reason is that for a song from e.g. YT music these are the media_title and media_artist attributes. Maybe in the case of radio you also need to provide data there.

melwinek commented 10 months ago

@OzGav Please reopen

OzGav commented 10 months ago

This is now a question as to whether the HA player card is displaying the info you want. It would actually not be correct to just put the stream title into the media_artist attribute. I think you should approach the HA card developers and ask them to support the stream_title attribute. If you don't want to do that you could go with a hacky approach if you wanted https://community.home-assistant.io/t/extend-sensor-with-custom-attribute/315688

melwinek commented 10 months ago

Maybe to media_title? After all, a stream is also media ;) Because music on YT is a stream and is filled with media_title.

OzGav commented 10 months ago

But then it would be in the top line of the player and you wouldn't see the station name. I recommend you follow my advice in the post above.

drosner commented 10 months ago

I get why stream and media are different logically and therefore this is an issue to be solved on the media card side. Question I have is where are these attributes defined and are they standard? Are these HA media player object attributes and defined somewhere in the core code base?

Just looking to see all the different attributes available to be populated and used...

Seems to player card needs better logic based on stream vs radio vs other media types...

OzGav commented 10 months ago

https://developers.home-assistant.io/docs/core/entity/media-player/

Obviously additional attributes can be used but I guess this is the starting point

drosner commented 10 months ago

Why not populate media_track with the current song title?

OzGav commented 10 months ago

Maybe... I would have to ask as the radio station I looked at is sending ARTIST - TRACK. Might be possible to split that up?

drosner commented 10 months ago

Oh I see...media_track is meant to be the track number and numeric.

So where is stream_title attribute defined? Is that a music assistant attribute only? If so then the issue (as you've said above) is the media_player core object needs to add attributes that solve this OR we add a custom attribute to our local or build our own media_player card. I use mini media player card myself...

drosner commented 10 months ago

There is also media_channel which is where the station name really should go. Then media_title should populate with the current song being streamed.

Now if different stream sources mix artist and title nothing you can do about that unless that is a universal streaming standard. I bet it's not and dependent on the streaming server used and maybe it's config. Or it's defined in stream protocol (ogg,mp3,etc...).

Then it's up to the card to display properly...

melwinek commented 10 months ago

That's why I think that media_title should be sent from MA to HA, not stream_title. Maybe someone has e.g. Volumio and can check what it's like there?

drosner commented 10 months ago

I've been looking through the HA code for the core media_player device and don't see any "stream" attributes or variables etc. So not sure what the purpose of custom MA attributes would be if the HA objects don't recognize or use the same attributes?

Should we open a new GitHub ticket to request the radio station name go in media_channel and then populate media_title and media_artist, etc. with the track meta data?

OzGav commented 10 months ago

You can create a feature request discussion about this and see how much traction you get. Changing the media title from what is currently shown may not suit everyone.

melwinek commented 10 months ago

What can you do in this case?: media_title = media_title + ' - ' + stream_title

marcelveldt commented 9 months ago

A streamtitle as set by radio stations is not standardized. Some radio stations set it some others do not. Some set it to "artist - song", some set it to "songtitle - artist" and again others use only the songtitle or radio station title. There is no standard for it. I have set it to the custom streamtitle attribute as a courtesy/service but I dont think it should be officially handled.

OR it must be handled as an optional metadata field for radio stations only. In that case we could also consider using something like "station name" for the radio station name (what we currently set as title)

drosner commented 9 months ago

I hear you but I think the issue is that for (radio) streaming the media title is being populated with the stream (station) name instead of what is being playing. Since different sources send inconsistent meta data the media title may be different but at least it won't be the radio station name. I think there are other attributes to put the stream or radio station name. Then populate media title with what is currently being played.

Ultimately the core media player component needs to be updated to support streaming sources....

drosner commented 9 months ago

Streaming source name (radio station) should go into media_channel attribute. The current playing song regardless of how the source sends it should go in media_title attribute.