#Passing Title/ Artist to Sonos When Playing .mp3 Stream via `media_content_id`

13 messages · Page 1 of 1 (latest)

acoustic perch
#

Hi,
I am developing an application that grabs content from YT and offers them as a plain, chunked mp3 stream via http. I can play this stream on my Sonos device via the respective integration calling play_media with:

{ "media_content_id": "x-rincon-mp3radio://http://<my local server>/<my streamed media>.mp3",    "media_content_type": "music"}

While playing the media works fine, I would also like to have title and artist displayed in my dashboard on the Sonos card, which currently stays blank, even while playing.

The docs for the integration don't really mention manually setting meta information for played media via http (only via plex). Does anyone know how to add this, maybe through an additional header?

spice gate
#

If you have another way of getting the metadata you can use the universal integration to template your media player

acoustic perch
#

I see! I wasn't aware of that integration, thanks for suggesting it. I think that is a good fallback if all else fails. I'll leave it open a little longer in case someone knows of a way to set the meta information directly on the device.

spice gate
#

I dont believe so, the device reports the metadata here

#

So the trick would be for the device to report metadata, but i wouldn't know what makes it do that

#

When I play a radio stream on my Sonos it just shows metadata

acoustic perch
#

that is true, but the meta data somehow has to be sent to the device as well. The docs for plex (bottom example) indicates that meta data can be set from the outside, so I guess it has to be doable in some way. I am just not very keen to reverse engineer Sonos' protocol

spice gate
#

I'm missing what part is setting the metadata in the docs

acoustic perch
#

sorry, I was referring to this part. Unless I misunderstand the plex protocol here and this actually means "go request a piece of media based on the following meta data from the server"

spice gate
#

Yep 🙂

acoustic perch
#

well... damn. I'm still weirded out by this. Even in the plex scenario, the server has to transmit the meta data at some point. So there has to be a mechanism to bundle the meta data with the stream, send it beforehand, or offer it for the device for fetching in some way

spice gate
#

I think that is something in the way files and streams are played

acoustic perch
#

I guess so. When I send the play_media request, I can see an initial request from the device in my server logs:

received request from ::ffff:192.168.1.xxx for /stream?url=xxxxxx with headers {
  "connection": "close",
  "host": "192.168.1.xxx:3003",
  "accept": "*/*",
  "user-agent": "Linux UPnP/1.0 Sonos/82.2-59204 (ZPS33)",
  "x-sonos-swgen": "2",
  "x-sonos-firmware": "82.2-59204",
  "x-sonos-muse-api": "1.43.1",
  "x-sonos-id-hash": "bAl4AJK1ccoTt3Rjx4CPeuc="
}

and then followed by more requests to retrieve the chunks. I think Sonos would accept additional information in the response to this first request, like the meta data. So I can probably send it to the device on http level, but not directly through the ingration. So I guess we are leaving homeassistant integration land now. 😬