本文介绍了我曾经能够在Chromecast测试版中获得接收者列表,但现在我不能...我缺少什么吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

几个月前,当我在Beta版中编写了一个简单的Chrome(浏览器)Chromecast应用时,我能够通过Javascript获取接收器列表,然后提示用户选择设备。

When I wrote a simple Chrome (Browser) Chromecast app in the beta a few months ago, I was able to get a list of receivers through Javascript, and then prompt the user to select the device.

现在我似乎无法做到这一点,而且我无法通过阅读API文档来弄清楚如何做到这一点。看来,我唯一能做的就是希望并祈祷我的用户弄清楚如何单击浏览器中的chromecast按钮。

Now I can't seem to do this, and I can't figure out how to do this by reading the API docs. It seems that the only thing I can do is hope and pray that my user figures out how to click the chromecast button in the browser.

Youtube具有chromecast视频旁边的按钮。我想通过Javascript做同样的事情!

Youtube, however, has a chromecast button right next to the video. I'd like to do the same thing, via Javascript!

我该怎么做?

推荐答案

使用新的Chrome Sender Cast SDK,此调用

With the new Chrome Sender Cast SDK, this call

chrome.cast.requestSession(onRequestSessionSuccess,onLaunchError);

chrome.cast.requestSession(onRequestSessionSuccess, onLaunchError);

始终会触发Cast扩展程序以打开带有设备列表的弹出窗口,供用户选择和打开会话。不会有返回给您的应用程序的设备ID列表,开发人员可以对其进行迭代。

will always trigger the Cast extension to open a pop-up with a list of devices for users to select and open a session. There won't be a list of device IDs returned to your app that developers can iterate though.

如何触发此调用取决于开发人员,并取决于您的用例。您有以下选择。
-具有可点击的Cast图标(例如YouTube),用户单击该图标可触发此调用,然后用户会看到与Cast扩展程序相关的弹出式窗口
-在加载页面时触发此调用您的应用与Cast有关,希望用户立即选择设备
-不要做任何特别的事情来触发此呼叫。在这种情况下,当用户单击Cast扩展程序图标时,他们可以选择并连接到Cast设备。如果页面没有Cast集成,或者在页面加载时初始化Cast API时,将创建Cast会话(或在存在时连接到Cast会话),则用户可以在此处进行标签镜像。

How to trigger this call is up to developers and depend on your use case. You have the following options. - Have a clickable Cast icon like YouTube that users click that triggers this call and then users see the pop-up to the top right corner associated with the Cast extension - Trigger this call upon your page load if your app is all about Cast and wants users to select a device right away - Don't do anything special to trigger this call. In this case when users click on the Cast extension icon, they can select and connect to a Cast device. From there, users can do tab mirror if your page has no Cast integration or a Cast session will be created (or connected to when existing) if you initialize Cast API upon page load.

这篇关于我曾经能够在Chromecast测试版中获得接收者列表,但现在我不能...我缺少什么吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 23:55