pychromecast
pychromecast copied to clipboard
Add customData to play_media method
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.
play_media( url, 'audio/mpeg', metadata = { 'foo': 'my custom metadata', 'bar': 'is this what you're talking about?' } )
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
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.
IOW, the metadata
parameter offers a superset of the functionality you're asking for.
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
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.
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.