0

I am using CCL to implement cast functionality in my android app. CCL has a target activity (the default is VideoCastControllerActivity) that it will launch when the user clicks on the mini player or on notifications. If I have other data that I want passed to that activity what is the correct way of doing this? The data is basically just an id number.

It looks like the MediaInfo data for the media your playing gets passed to the activity in the form of a bundle. I see on that there is a JSON field to pass other custom data.

void setCustomData(org.json.JSONObject customData) { /* compiled code */ }

public org.json.JSONObject getCustomData() { /* compiled code */ }

I could convert that id number to JSON and put it in with the media info but I am not sure if I am misusing that attribute or is that what its meant to be used for? Is there another more clean approach?

Sufian
  • 6,405
  • 16
  • 66
  • 120
startoftext
  • 3,846
  • 7
  • 40
  • 49
  • The customData on the MediaInfo is passed to the Cast receiver. This is also returned as part of the mVideoCastManager.getRemoteMediaInformation().getCustomData(). Typically this is used for identifying the remote media playing so you could send in data such as your local media Id. Where do you intend to use the id number? If its for correlating the remotely playing media then that's the best approach. – Nagesh Susarla Jan 07 '15 at 19:21
  • There is some other custom data that is displayed in my custom player activity that is specified as a target when initializing VideoCastManager (basically my custom VideoCastControllerActivity). All I need is that ID number there to fetch and restore that data from a content provider to display in the player activity. – startoftext Jan 07 '15 at 20:09
  • You can use the customData field of the MediaInfo; that is passed along (after serialization and deserialization) to the VideoCastControllerActivity. It is also passed to the receiver but as long as your receiver doesn't care about that data, it shouldn't matter. – Ali Naddaf Jan 07 '15 at 21:18
  • Thanks Ali. I was hoping you would chime in and confirm that this was ok. Can you put that as an answer so I can go ahead and accept it to mark this question as answered. – startoftext Jan 07 '15 at 21:33

1 Answers1

0

There is another way to send custom data using custom channel something like this

  Cast.CastApi.sendMessage(mApiClient, Namespace, message)
                    .setResultCallback(new ResultCallback<Status>() {

                        @Override
                        public void onResult(Status result) {
// result
  }

     });
JosephM
  • 2,935
  • 4
  • 18
  • 28