pychromecast icon indicating copy to clipboard operation
pychromecast copied to clipboard

Add customData to play_media method

Open jhutchins opened this issue 6 years ago • 7 comments

It would be nice to be able to optionally add customData to the play request. I'm thinking to most straightforward option is to just add it as a defaulted parameter. Although it's could be added as a **kwargs parameter which I can't decide if that's a clever or crappy idea, but I'm leaning towards crappy.

jhutchins avatar Jan 06 '19 03:01 jhutchins

play_media( url, 'audio/mpeg', metadata = { 'foo': 'my custom metadata', 'bar': 'is this what you're talking about?' } )

stefan-sherwood avatar Sep 17 '19 17:09 stefan-sherwood

No, there's a parameter in the load request object specifically called customData.

https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.messages.LoadRequestData#customData

jhutchins avatar Sep 17 '19 18:09 jhutchins

I guess it depends on why you want to set the customData. When you include the metadata parameter as shown in my snippet that data is included in any notifications or queries of what is currently playing. You could probably use metadata = { 'media_custom_data': 'your stuff' } but I haven't tried that.

stefan-sherwood avatar Sep 17 '19 22:09 stefan-sherwood

IOW, the metadata parameter offers a superset of the functionality you're asking for.

stefan-sherwood avatar Sep 17 '19 22:09 stefan-sherwood

It absolutely does not. For example, if you're trying to setup a custom MediaPlaybackInfoHandler[0] the parameters passed to your callback give you access to the customData, but not to the metadata. [1]

[0] https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.PlayerManager#setMediaPlaybackInfoHandler [1] https://developers.google.com/cast/docs/reference/caf_receiver/cast.framework.messages.LoadRequestData

jhutchins avatar Sep 18 '19 02:09 jhutchins

I am using PyChromecast and not the Google APIs directly. I have two separate Python apps using PyChromecast, running on two different computers. One plays music and the other listens for media state changes. The one that receives the state changes gets the custom metadata fields that my player sets in the play_media command.

stefan-sherwood avatar Sep 18 '19 03:09 stefan-sherwood

That's great I suppose for your use case, but that does not help in the case of adding custom authentication to a CAF application running on an actual Chromecast which is the canonical use case for the customData property.

jhutchins avatar Sep 19 '19 14:09 jhutchins