如何通过URL将自定义数据/参数传递给Chromecast接收器?

时间:2020-12-10 15:15:43

Is it possible to have a Chromecast sender application to pass custom data to the receiver in the URL? The goal is to pass user-specific data to the receiver so it can generate the appropriate contents each time it's called.

是否可以让Chromecast发送者应用程序将自定义数据传递到URL中的接收者?目标是将用户特定的数据传递给接收者,以便每次调用时都可以生成适当的内容。

An example of this would be a simple to-do list. When the user casts to their device, that user's data should be passed via URL to the receiver so that their task list can be loaded in the custom receiver.

这方面的一个例子是一个简单的待办事项列表。当用户转换到他们的设备时,该用户的数据应该通过URL传递给接收者,以便他们的任务列表可以加载到自定义接收器中。

I haven't seen any tutorials or much information on this in the Cast documentation.

我在Cast文档中没有看到任何关于此的教程或更多信息。

2 个解决方案

#1


If you mean passing parameters as part of the receiver url that loads the receiver, the answer is no; there is no such thing. You can either use the customData that can be passed to the receiver in a number of APIs, or you can create a custom data channel if the former is not adequate for your needs.

如果你的意思是传递参数作为加载接收器的接收器URL的一部分,答案是否定的;哪有这回事。您可以使用可以在许多API中传递给接收器的customData,也可以创建自定义数据通道(如果前者不足以满足您的需求)。

#2


The Cast receiver URL is specified as a static URL when you're registering/publishing the app on the Google Cast SDK Developer Console so it is not possible to add custom parameters.

当您在Google Cast SDK开发者控制台上注册/发布应用程序时,Cast接收者URL被指定为静态URL,因此无法添加自定义参数。

However you can use the Cast Messages system to send data between a Cast sender and Cast receiver. It's similar to the messaging system in modern browsers.

但是,您可以使用Cast Messages系统在Cast发送者和Cast接收者之间发送数据。它类似于现代浏览器中的消息传递系统。

#1


If you mean passing parameters as part of the receiver url that loads the receiver, the answer is no; there is no such thing. You can either use the customData that can be passed to the receiver in a number of APIs, or you can create a custom data channel if the former is not adequate for your needs.

如果你的意思是传递参数作为加载接收器的接收器URL的一部分,答案是否定的;哪有这回事。您可以使用可以在许多API中传递给接收器的customData,也可以创建自定义数据通道(如果前者不足以满足您的需求)。

#2


The Cast receiver URL is specified as a static URL when you're registering/publishing the app on the Google Cast SDK Developer Console so it is not possible to add custom parameters.

当您在Google Cast SDK开发者控制台上注册/发布应用程序时,Cast接收者URL被指定为静态URL,因此无法添加自定义参数。

However you can use the Cast Messages system to send data between a Cast sender and Cast receiver. It's similar to the messaging system in modern browsers.

但是,您可以使用Cast Messages系统在Cast发送者和Cast接收者之间发送数据。它类似于现代浏览器中的消息传递系统。