我目前正在建立一个网站,我希望有一个显示Google Cast的功能。是否可以使用HTML和JavaScript,没有复杂的东西。
答案 0 :(得分:6)
只需使用Chrome Sender API即可。来自Official Integration docs:
投射按钮
应用中的Cast按钮组件完全由框架处理。这包括可见性管理以及单击事件处理。 button元素标记需要
is='google-cast-button'
属性才能被框架识别。<button is="google-cast-button"></button>
或者,您可以以编程方式创建按钮:
document.createElement('button', 'google-cast-button')
您可以根据需要对元素应用任何其他样式,例如大小或位置。使用
--connected-color
属性为连接的接收器状态选择颜色,并为断开连接状态选择--disconnected-color
。
有关详细信息,请参阅文档。