Youtube 实时聊天嵌入在移动设备中不起作用 [英] Youtube live chat embed not working in mobile
本文介绍了Youtube 实时聊天嵌入在移动设备中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube.com/live_chat?v=XX71LoT8AME&embed_domain=localhost" width="480"></iframe>
这是嵌入 youtube 实时聊天的 Iframe 代码.它在桌面视图中工作正常,但在移动视图中返回一个 javascript 错误并且没有显示任何内容
解决方案
官方 YouTube 文档
<块引用>嵌入实时聊天
注意:在移动设备上无法嵌入实时聊天网.
在直播期间,您可以通过以下方式在自己的网站上嵌入实时聊天使用 iframe.
- 获取直播的视频 ID.您可以从观看页面网址 (youtube.com/watch?v=12345).在这种情况下,视频 ID 是12345".如果您选择立即直播",请右键单击播放器并选择复制视频 URL 以获取视频 URL.
- 获取域您要嵌入聊天的站点的 URL.如果您要嵌入聊天在 www.example.com/youtube_chat 上,您的嵌入域是www.example.com."
- 按以下方式组合嵌入的 URL:https://www.youtube.com/live_chat?v=12345&embed_domain=www.example.com.
- 这是您的 iframe 的网址.注意 embed_domain 必须匹配您嵌入聊天的页面的 URL.如果它们是不同的是,嵌入式聊天不会加载.
<iframe allowfullscreen="" frameborder="0" height="500" src="https://www.youtube.com/live_chat?v=XX71LoT8AME&embed_domain=localhost" width="480"></iframe>
This is the Iframe code for the youtube live chat embed. It works fine in desktop view but return a javascript error in mobile view and no content is shown
解决方案
Official YouTube documentation
Embed Live chat
Note: embedding live chat isn't available on mobile web.
During a live stream, you can embed live chat on your own site by using an iframe.
- Get the video ID for the live stream. You can get the video ID from the watch page URL (youtube.com/watch?v=12345). In this case, the video ID is ‘12345’. If you chose "Stream now," right-click on the player and select Copy video URL to get the video URL.
- Get the domain URL for the site you want to embed chat on. If you're embedding chat on www.example.com/youtube_chat, your embedding domain is "www.example.com."
- Combine the embedded URL in the following way: https://www.youtube.com/live_chat?v=12345&embed_domain=www.example.com.
- This is the URL for your iframe. Note the embed_domain must match the the URL of the page you’re embedding the chat on. If they are different, the embedded chat will not load.
这篇关于Youtube 实时聊天嵌入在移动设备中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文