如何在我的网站中嵌入带有深色主题的youtube实时聊天页面

时间:2020-03-26 09:58:48

标签: youtube youtube-api

我想将youtube实时聊天页面嵌入我的网站。我用以下代码成功实现了它。

<iframe src="https://www.youtube.com/live_chat?v=xxxxxx&embed_domain=localhost" frameborder="0"></iframe>

默认主题为浅色主题,但我的网站使用深色主题。

我知道Youtube有两个主题,包括浅色和深色,因此我想更改嵌入式实时聊天页面的主题。

我尝试在url上添加'theme = dark',但它不起作用。

那么有什么办法吗?

谢谢。

2 个答案:

答案 0 :(得分:3)

现在,您可以将参数添加到URL地址dark_theme=1

https://www.youtube.com/live_chat?v=xxxxxx&embed_domain=localhost&dark_theme=1

答案 1 :(得分:0)

也许有点hack。当您访问gaming.youtube.com时,YouTube会自动切换到“暗模式”。这也适用于嵌入式聊天。因此,这应该可以解决问题:

<iframe src="https://gaming.youtube.com/live_chat?v=xxxxxx&embed_domain=localhost" frameborder="0"></iframe>

编辑:嵌入聊天功能不适用于现代浏览器。可以在这里找到更多信息:How to embed youtube livestream chat