iframe - 无法播放YouTube视频后正确设置相关视频

标签 iframe youtube

在尝试播放YouTube电影后,我试图将推荐视频设置为该 channel 的视频,但是我写错了。
这是我的iframe逻辑:

<iframe 
 src="https://www.youtube.com/embed/VIDEO_ID?listType=user_uploads&list=CHANNEL_ID?autoplay=1"
></iframe>

这是真实的代码:
<iframe 
 src="https://www.youtube.com/embed/LKKQpX5ucGk?listType=user_uploads&list=UC-k6oG4r4vQjeoMZlEHzQmw?autoplay=1"
></iframe>

最佳答案

您可以通过向您的src中添加rel=0来限制相关视频来自同一 channel

以下有您想要的效果

<iframe width="560" height="315" src="https://www.youtube.com/embed/boPZ_0E6X6s?rel=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>

关于iframe - 无法播放YouTube视频后正确设置相关视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56055391/

相关文章:

javascript - 如果从 javascript 更改,iFrame 不显示结果

iPhone - 在 iPhone 应用程序中使用 YouTube API

html - 嵌入 iframe HTML 中不可用的 YouTube 视频

c# - 将 Youtube/Vimeo 视频嵌入电子邮件模板

javascript - 我可以使用 window.postMessage 方法从 iframe 中的网页与包含该 iframe 的 UIWebView 进行通信吗?

javascript - 使用 React 定期重新加载 iframe 的最佳方法是什么?

cookies - 在 youtube-nocookie.com 域中使用 YouTube IFrame Player API 脚本时禁用 cookie

youtube - 关注YouTube数据API上的特定主题

javascript - 实现 iframe 的顶部和底部水平滚动条

javascript - Bootstrap Modal - 根据 iframe 高度调整模态大小