2

I am trying to get the sender application language from Chromecast receiver in the first connection (before loading any stream) to show a welcome message.

I have this in my sender code to set the options:

cast.framework.CastContext.getInstance().setOptions({
    receiverApplicationId: castReceiverId,
    autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED,
    language: languageService.getCurrentLanguage().iso6393,
    resumeSavedSession: true,
});

Is there a way to recover these params in the receiver code?

1 Answers1

1

I have not found the way to recover init options, but I have set a custom namespace to pass a message through it from sender to receiver once the connection is set.

In Sender:

const customNameSpace = 'urn:x-cast:google.cast.custom';
const msg = {lang: senderApplicationLanguage};
context.getCurrentSession().sendMessage(customNameSpace, msg, onSuccess, onError);

Then just wait for it in receiver

const customNameSpace = 'urn:x-cast:google.cast.custom';
this.context.addCustomMessageListener(customNameSpace, (event) => {
    const lang = event.data.lang;
});

Hope this helps someone!