0

According to the Google Custom Receiver documentation, if our app performs authentication we can load the customData in json format in our sender application. In my case, I did something similar to the following,

MediaInfo mediaInfo = new MediaInfo.Builder(
           "url")
             .setStreamType(MediaInfo.STREAM_TYPE_BUFFERED)
             .setCustomData(jsonCustomData) 
             .build();

Then loaded the mediaInfo like the following,

mRemoteMediaPlayer.load(mApiClient, mediaInfo, true).setResultCallback(....);

In my receiver application, I tried to retrieve the jsonCustomData like the following,

var customData = window.mediaManager.LoadRequestData.customData;

However, it doesn't seem like it's working. I've noticed that in some sample apps, some people use the Cast.CastApi.sendMessage method, and use window.message.onMessage=function(event) where event.data would contain the message. Could someone explain the difference between these two methods? what am I doing wrong?

Notice my receiver code is not wrapped a window.onload function, do I need to?

Thanks for the help!

jensiepoo
  • 571
  • 3
  • 9
  • 26

1 Answers1

2

You may want to hook into mediaManager.onLoad(event) callback (see this for how to do that properly; you need to make sure you call the original onLoad in your implementation). Then, if my memory serves me right, event.data should be of the type cast.receiver.mediaManager.LoadRequestData. If so, event.data.media.customData should have the custom data that you specified in your mediaInfo. If you use customData in your mRemoteMediaPlayer.load() command (instead of the mediaInfo), then it should be accessible in the same callback but through event.data.customData. Please validate this against the receiver API reference to make sure they are correct.

Ali Naddaf
  • 16,951
  • 2
  • 21
  • 28
  • MediaInfo is something you pass into .load() as a parameter. – jensiepoo Oct 26 '15 at 19:29
  • Because you said "If you use customData in your mRemoteMediaPlayer.load() command (instead of the mediaInfo)." And I'm saying that these two things are not mutually exclusive where customData is what you construct MediaInfo with, and MediaInfo is a parameter that you pass into .load(). That's all! Thanks for the help! – jensiepoo Oct 26 '15 at 20:24