How can I send a message to a custom Google Cast Receiver from Chrome for iOS?

元气小坏坏 提交于 2019-12-13 01:29:24

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/27160320/how-can-i-send-a-message-to-a-custom-google-cast-receiver-from-chrome-for-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!