如何从Chrome for iOS发送消息给自定义Google Cast Receiver? [英] How can I send a message to a custom Google Cast Receiver from Chrome for iOS?

查看:450
本文介绍了如何从Chrome for iOS发送消息给自定义Google Cast Receiver?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 CastHelloText-chrome 示例,并且能够让所有工作都正常运行但是,当我尝试在我的iOS设备上使用Chrome时,尝试创建会话时收到以下错误消息:


{code:channel_error,description:操作无法完成(com.google.chrome.ios.cast错误2)}


执行以下操作时会发生此错误:

  chrome .cast.requestSession(function(e){
session = e;
session.sendMessage(namespace,message,onSuccess.bind(this,Message sent:+ message),onError);
},onError);

具体来说,这似乎发生在 requestSession 函数调用(嵌套回调从未实际执行)。



直到这一点似乎都行得通。事实上,在我的iOS设备上,我甚至会收到弹出式窗口,询问投向哪里(Chromecast),一旦我选择它,我的Chromecast确实会显示我的自定义接收器。然而,我仍然收到这个错误消息,并且从来没有得到一个会话对象,所以我不能发送消息到接收器。



就像我说的,这似乎工作正常在我的桌面版Chrome浏览器上,但无法在iOS Chrome浏览器上运行。此示例不适用于iOS设备吗?有没有一种方法可以使它工作? 解决方案

手机上的Chrome和手机上的Chrome并不相同。您需要使用 iOS API 。以 CastHelloText-ios 作为参考使用示例应用程序。

I'm using the CastHelloText-chrome example and am able to get it all working just fine from the Chrome browser on my desktop, however, when I try to use Chrome on my iOS device, I receive the following error when trying to create a session:

{ "code": "channel_error", "description": "The operation couldn't be completed. (com.google.chrome.ios.cast error 2.)" }

This error happens when executing the following:

chrome.cast.requestSession(function(e) {
    session = e;
    session.sendMessage(namespace, message, onSuccess.bind(this, "Message sent: " + message), onError);
  }, onError);

Specifically, this seems to happen on the requestSession function call (the nested callback never actually executes).

Everything up until this point seems to work. In fact, on my iOS device, I even receive the popup asking where to cast to (Chromecast) and once I select it, my Chromecast does indeed display my custom receiver. However, I still receive that error message and never get a session object, so I can't send messages to the receiver.

Like I said, this seems to work fine on my desktop Chrome browser, but does not work on my iOS Chrome browser. Does this sample not work on iOS devices? Is there a way to make it work?

解决方案

Chrome on desktop and Chrome on mobile are not the same. You need to use the iOS API. Use the sample app for CastHelloText-ios as a reference.

这篇关于如何从Chrome for iOS发送消息给自定义Google Cast Receiver?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆