Update Chromecast MediaMetadata

2019-08-06 09:04发布

问题:

I'm playing a live HLS stream in a Chromecast app, and I'm wanting to update the MediaMetadata when programmes start/finish. However I can't find a method to do this. I can load the stream again with fresh MediaInfo, but I can't just update the existing metadata. Is there any way to do this?

At present I'm casting from an Android app.

Is there a way to send fresh MediaMetadata to the receiver, or can I pass a custom data message with the information, and update the metadata within the sender using javascript?

回答1:

see 'CCL' in general for the interfaces to manipulate things like metaData on events like onRemoteStatusChange()...

Looking at that, IMO if you want to alter the message type below to "METADATA_CHANGE" OR whatever it would be for a change in the mediaInfo, then just send the message to the receiver and you should get the broadcast you want... onMediaDataChanged().

sample msg from receiver to CastMgr...

{"requestId":0,"status":{"applications":[{"appId":"33E59692","displayName":"test-receiver-app","namespaces":[{"name":"urn:x-cast:com.google.cast.player.message"},{"name":"urn:x-cast:com.google.cast.media"}],"sessionId":"0869F8A7-25CE-E55F-F571-346EBABB81FB","statusText":"Ready To Cast","transportId":"web-3"}],"isActiveInput":true,"volume":{"level":1.0,"muted":false}},"type":"RECEIVER_STATUS"}

onRemoteMediaPlayerStatusUpdated()

When the receiver goes from PLAY to IDLE at the end of a video , the status change event is called on all 'listeners' ie all implementations of IVideoCastConsumer that have registered as listeners for 'status-changed'.

In the Base CCL class of BaseCastManager, you can watch for this specific status change and then broadcast your onRemoteMediaPlayerMetadataUpdated() event and all observers will get appropriate callback on that.... OR listen on event and just send the correct type of message to the receiver.

If its not exactly intended to observe mediaMetaDataChanges IMO , looking it over may help you tweek the existing API with and @Override in order to get your desire result.