【问题标题】:Get sender language in Chromecast Receiver在 Chromecast Receiver 中获取发件人语言
【发布时间】:2020-10-28 12:21:00
【问题描述】:

我正在尝试在第一次连接中(在加载任何流之前)从Chromecast 接收方获取发送方应用程序语言以显示欢迎消息。

我的发件人代码中有此设置选项:

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

有没有办法在接收器代码中恢复这些参数?

【问题讨论】:

    标签: chromecast google-cast google-cast-sdk


    【解决方案1】:

    我还没有找到恢复初始化选项的方法,但是我设置了一个自定义命名空间,以便在设置连接后将消息从发送者传递到接收者。

    在发件人中:

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

    然后在接收器中等待它

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

    希望这对某人有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-12-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-23
      • 2013-12-19
      • 1970-01-01
      相关资源
      最近更新 更多