是否可以从本机应用程序将视频发送到 chromecast 设备?共享系统上的任何窗口而不是仅共享 chrome 选项卡会很好。此外,是否有任何关于 chrome 用于与 chromecast 通信的通信文档?据我了解,chromecast 本质上是从嵌入式 chrome 实例加载内容,但似乎有更直接的方式与设备通信,因为它能够使用扩展从 chrome 选项卡流式传输内容。
2 回答
You need to whitelist your receiver device if you are developing a receiver application. That would be a Chome app that runs on the receiver's Chrome instance.
You need to whitelist a sender url if you are developing a Chrome app that will cast it's contents.
Video casting works by sending a url to the receiver device, which the device will load directly.
Tab casting works by encoding the tab contents using WebM/Opus (in the Chrome cast extension) and streaming that to the receiver device. (This is limited to 720p, see this question)
Chrome apps can only use Video casting.
The chrome cast extension is going to be the only way to stream directly to the device.
So the answer to your question is no, you cannot stream video directly to the device. The receiver must load the video from the url you provide.
There is some speculation whether the receiver can be provided with a local url or if it must already be available on the internet. This has yet to be clarified.
根据我对 Chromecast 架构的理解:
您可以在电视上显示您想要的任何 URL(您必须先将您的应用列入白名单并注册 URL)。它必须是一个 URL。这可以包括 HTML、JS、CSS 等。互联网上已经存在的任何内容。
要从设备接收数据(例如,要加载的视频的 URL),您必须实现逻辑来解释来自频道的消息。这些消息被编码为 JSON,这使得发送视频或图片(二进制数据)变得困难。将这样的内容上传到某个网站并让接收者显示它们显然是最简单的。
人们问,“那么,标签/屏幕共享是如何工作的?” JSON 编码正是 Google 在其 SDK 中提供的。在他们自己的来源中,他们没有这个限制。
更新:事实证明,您只需在 Chrome 中打开本地文件,然后将其投射到电视上,就可以将本地视频流式传输到电视上。